xslt:transform and white-space pb

Wednesday, 4 February 2015 · 5 messages · last reply 5 Feb 2015
EM
Emmanuelle Morlock4 Feb 2015 22:12 #
Hi all, I'm using baseX 7.9 with GUI My query declares an chop option set to "no" ("declare option db:chop 'no';") and uses "return xslt:transform($in, $style)". But after running it, all the white-spaces in the xslt rules are chopped. for example the space in "<xsl:text> </xsl:text>" of a named template is not in the resulting html file. What can I do to solve the pb ? Thanks for your help Cheers Emmanuelle
-- Emmanuelle Morlock IGE CNRS - soutien aux projets d'édition TEI - humanités numériques -------------------------- UMR 5189 HISoMA http://www.hisoma.mom.fr/ 04 72 71 58 40 06 85 84 69 16 @emma_morlock ------------------------- Membre du comité de coordination d'Humanistica, association francophone des Humanités numériques <http://www.humanisti.ca>
CG
Christian Grün4 Feb 2015 22:19 #
Hi Emmanuelle, Could you please check if the problem has already been solved in Version 8.0 [1]? If not, could you possibly provide us with a small example? Thanks in advance, Christian [1] http://files.basex.org/releases/latest
Quoted text · Emmanuelle Morlock · 37 lines
On Wed, Feb 4, 2015 at 10:12 PM, Emmanuelle Morlock <emmanuelle.morlock at mom.fr> wrote: > > Hi all, > > I'm using baseX 7.9 with GUI > > My query declares an chop option set to "no" ("declare option db:chop > 'no';") > and uses "return xslt:transform($in, $style)". > > But after running it, all the white-spaces in the xslt rules are chopped. > for example the space in "<xsl:text> </xsl:text>" of a named template is > not in the resulting html file. > > What can I do to solve the pb ? > > Thanks for your help > > Cheers > > Emmanuelle > > -- > Emmanuelle Morlock > IGE CNRS - soutien aux projets d'édition TEI - humanités numériques > -------------------------- > UMR 5189 HISoMA > http://www.hisoma.mom.fr/ > 04 72 71 58 40 > 06 85 84 69 16 > @emma_morlock > ------------------------- > Membre du comité de coordination d'Humanistica, association francophone des > Humanités numériques <http://www.humanisti.ca> > >
EM
Emmanuelle Morlock4 Feb 2015 22:57 #
Hi Christian, The pb seems to still be the same. Please find attached : - the xml file for the database (my_biblio.xml) - the query I want a space between the title and the publication year, which should be provided by the <xsl:text> </xsl:text> of the named template :
<xsl:template name="publicationDate">
         <xsl:text> </xsl:text>
         <xsl:apply-templates select="monogr/imprint/date/@when"/>
     </xsl:template>
so the result should be :
  <span class="title">Khartoum Greek</span>, 2003</li>
but the result is
<span class="title">Khartoum Greek</span>,2003</li>
Thanks in advance best emmanuelle
Quoted text · Christian Grün · 51 lines
Le 04/02/2015 22:19, Christian Grün a écrit : > Hi Emmanuelle, > > Could you please check if the problem has already been solved in > Version 8.0 [1]? > > If not, could you possibly provide us with a small example? > > Thanks in advance, > Christian > > [1] http://files.basex.org/releases/latest > > > > On Wed, Feb 4, 2015 at 10:12 PM, Emmanuelle Morlock > <emmanuelle.morlock at mom.fr> wrote: >> Hi all, >> >> I'm using baseX 7.9 with GUI >> >> My query declares an chop option set to "no" ("declare option db:chop >> 'no';") >> and uses "return xslt:transform($in, $style)". >> >> But after running it, all the white-spaces in the xslt rules are chopped. >> for example the space in "<xsl:text> </xsl:text>" of a named template is >> not in the resulting html file. >> >> What can I do to solve the pb ? >> >> Thanks for your help >> >> Cheers >> >> Emmanuelle >> >> -- >> Emmanuelle Morlock >> IGE CNRS - soutien aux projets d'édition TEI - humanités numériques >> -------------------------- >> UMR 5189 HISoMA >> http://www.hisoma.mom.fr/ >> 04 72 71 58 40 >> 06 85 84 69 16 >> @emma_morlock >> ------------------------- >> Membre du comité de coordination d'Humanistica, association francophone des >> Humanités numériques <http://www.humanisti.ca> >> >>
-- Emmanuelle Morlock IGE CNRS - soutien aux projets d'édition TEI - humanités numériques -------------------------- UMR 5189 HISoMA http://www.hisoma.mom.fr/ 04 72 71 58 40 06 85 84 69 16 @emma_morlock ------------------------- Membre du comité de coordination d'Humanistica, association francophone des Humanités numériques <http://www.humanisti.ca>
GB
Gioele Barabucci5 Feb 2015 10:22 #
Quoted text · Emmanuelle Morlock · 5 lines
Am 04.02.2015 um 22:57 schrieb Emmanuelle Morlock: > I want a space between the title and the publication year, which should > be provided by the <xsl:text> </xsl:text> of the named template : > > <xsl:text> </xsl:text>
What about
     <xsl:text xml:space="preserve"> </xsl:text>
? Anyway, I would suggest using something like
     <xsl:variable name="char-space"
         xml:space="preserve"><xsl:text>&#32;</xsl:text></xsl:variable>
and
     <xsl:value-of select="$char-space"/>
So that it is easier to understand which character is being added and there are less chances that the various formatters will mangle the code. Regards,
-- Gioele Barabucci <gioele at svario.it>
CG
Christian Grünin reply to Emmanuelle Morlock, 4 Feb 2015, 22:575 Feb 2015 12:56 #
Hi Emmanuelle, Gioele already gave you the answer (thanks): You need to explicitly encode the whitespace in one of the following ways:
  <xsl:text>&#32;</xsl:text>
  <xsl:text>&#x20;</xsl:text>
  <xsl:text><![CDATA[ ]]></xsl:text>
  <xsl:text>{ ' ' }</xsl:text>
The reason is that XQuery ignores empty text nodes, no matter what option you choose (unfortunately, even xml:space won't help, and db:chop only applies to BaseX document or database instances). As an alternative, you can store the XSLT document in a file. Best, Christian
Quoted text · Emmanuelle Morlock · 100 lines
On Wed, Feb 4, 2015 at 10:57 PM, Emmanuelle Morlock <emmanuelle.morlock at mom.fr> wrote: > Hi Christian, > > The pb seems to still be the same. > > Please find attached : > - the xml file for the database (my_biblio.xml) > - the query > > I want a space between the title and the publication year, which should be > provided by the <xsl:text> </xsl:text> of the named template : > > <xsl:template name="publicationDate"> > <xsl:text> </xsl:text> > <xsl:apply-templates select="monogr/imprint/date/@when"/> > </xsl:template> > > so the result should be : > > <span class="title">Khartoum Greek</span>, 2003</li> > > but the result is > > <span class="title">Khartoum Greek</span>,2003</li> > > > Thanks in advance > > best > > emmanuelle > > Le 04/02/2015 22:19, Christian Grün a écrit : > > Hi Emmanuelle, > > Could you please check if the problem has already been solved in > Version 8.0 [1]? > > If not, could you possibly provide us with a small example? > > Thanks in advance, > Christian > > [1] http://files.basex.org/releases/latest > > > > On Wed, Feb 4, 2015 at 10:12 PM, Emmanuelle Morlock > <emmanuelle.morlock at mom.fr> wrote: > > Hi all, > > I'm using baseX 7.9 with GUI > > My query declares an chop option set to "no" ("declare option db:chop > 'no';") > and uses "return xslt:transform($in, $style)". > > But after running it, all the white-spaces in the xslt rules are chopped. > for example the space in "<xsl:text> </xsl:text>" of a named template is > not in the resulting html file. > > What can I do to solve the pb ? > > Thanks for your help > > Cheers > > Emmanuelle > > -- > Emmanuelle Morlock > IGE CNRS - soutien aux projets d'édition TEI - humanités numériques > -------------------------- > UMR 5189 HISoMA > http://www.hisoma.mom.fr/ > 04 72 71 58 40 > 06 85 84 69 16 > @emma_morlock > ------------------------- > Membre du comité de coordination d'Humanistica, association francophone des > Humanités numériques <http://www.humanisti.ca> > > > > > -- > Emmanuelle Morlock > IGE CNRS - soutien aux projets d'édition TEI - humanités numériques > -------------------------- > UMR 5189 HISoMA > http://www.hisoma.mom.fr/ > 04 72 71 58 40 > 06 85 84 69 16 > @emma_morlock > ------------------------- > Membre du comité de coordination d'Humanistica, association francophone des > Humanités numériques <http://www.humanisti.ca>

⚡Generated with XQuery