Whitespace anomaly running XSLT from BaseX
Thursday, 28 February 2013 · 7 messages · last reply 1 Mar 2013
DK
Hello,
Please take a look at the CHOP database option, I guess that will fix it: http://docs.basex.org/wiki/Options#CHOP
Cheers,
Dirk
On Thu, Feb 28, 2013 at 5:49 PM, Wendell Piez <wapiez at wendellpiez.com>wrote:
Quoted text · Wendell Piez · 36 lines
> Friends, > > I am encountering an odd whitespace-handling anomaly in BaseX when > invoking Saxon to transform files behind RESTXQ. > > Briefly, if I have this in my XSLT: > > <xsl:text> </xsl:text> > > (the common way to get a space character in my result) > > I get nothing, and this > > <xsl:text> Boo! </xsl:text> > > gets me "Boo!" (leading and trailing whitespace trimmed). > > But I can't duplicate this behavior running BaseX from the GUI. > > I am sure there is a 'trim' or 'chop' setting somewhere that is > allowing this, but I don't know where to look. > > Any ideas? > > Thanks, Wendell > > -- > Wendell Piez | http://www.wendellpiez.com > XML | XSLT | electronic publishing > Eat Your Vegetables > _____oo_________o_o___ooooo____ooooooo_^ > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
--
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
WP
Wendell Piez28 Feb 2013 18:49 #
Friends,
I am encountering an odd whitespace-handling anomaly in BaseX when invoking Saxon to transform files behind RESTXQ.
Briefly, if I have this in my XSLT:
<xsl:text> </xsl:text>(the common way to get a space character in my result)
I get nothing, and this
<xsl:text> Boo! </xsl:text>gets me "Boo!" (leading and trailing whitespace trimmed).
But I can't duplicate this behavior running BaseX from the GUI.
I am sure there is a 'trim' or 'chop' setting somewhere that is allowing this, but I don't know where to look.
Any ideas?
Thanks, Wendell
--
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
WP
Hi again,
Sorry if I wasn't clear enough. The XSLT is not in the database; it is called from the file system.
I just checked, and I'm seeing the same behavior whether the database is created with 'chop' on or off. Again, this under RESTXQ; when calling the same XSLT from the GUI, everything is fine.
Cheers, Wendell
Quoted text · Dirk Kirsten · 58 lines
On Thu, Feb 28, 2013 at 12:18 PM, Dirk Kirsten <dk at basex.org> wrote: > Hello, > > Please take a look at the CHOP database option, I guess that will fix it: > http://docs.basex.org/wiki/Options#CHOP > > Cheers, > Dirk > > > On Thu, Feb 28, 2013 at 5:49 PM, Wendell Piez <wapiez at wendellpiez.com> > wrote: >> >> Friends, >> >> I am encountering an odd whitespace-handling anomaly in BaseX when >> invoking Saxon to transform files behind RESTXQ. >> >> Briefly, if I have this in my XSLT: >> >> <xsl:text> </xsl:text> >> >> (the common way to get a space character in my result) >> >> I get nothing, and this >> >> <xsl:text> Boo! </xsl:text> >> >> gets me "Boo!" (leading and trailing whitespace trimmed). >> >> But I can't duplicate this behavior running BaseX from the GUI. >> >> I am sure there is a 'trim' or 'chop' setting somewhere that is >> allowing this, but I don't know where to look. >> >> Any ideas? >> >> Thanks, Wendell >> >> -- >> Wendell Piez | http://www.wendellpiez.com >> XML | XSLT | electronic publishing >> Eat Your Vegetables >> _____oo_________o_o___ooooo____ooooooo_^ >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > > -- > Dirk Kirsten, BaseX GmbH, http://basex.org > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > | Dr. Christian Grün, Alexander Holupirek, Michael Seiferle > `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
--
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
CG
Christian Grün1 Mar 2013 11:42 #
Hi Wendell,
do you have a little code snippet that allows us reproduce the problem?
Best,
Christian
Quoted text · Wendell Piez · 84 lines
On Thu, Feb 28, 2013 at 9:05 PM, Wendell Piez <wapiez at wendellpiez.com> wrote: > Hi again, > > Sorry if I wasn't clear enough. The XSLT is not in the database; it is > called from the file system. > > I just checked, and I'm seeing the same behavior whether the database > is created with 'chop' on or off. Again, this under RESTXQ; when > calling the same XSLT from the GUI, everything is fine. > > Cheers, Wendell > > > > On Thu, Feb 28, 2013 at 12:18 PM, Dirk Kirsten <dk at basex.org> wrote: >> Hello, >> >> Please take a look at the CHOP database option, I guess that will fix it: >> http://docs.basex.org/wiki/Options#CHOP >> >> Cheers, >> Dirk >> >> >> On Thu, Feb 28, 2013 at 5:49 PM, Wendell Piez <wapiez at wendellpiez.com> >> wrote: >>> >>> Friends, >>> >>> I am encountering an odd whitespace-handling anomaly in BaseX when >>> invoking Saxon to transform files behind RESTXQ. >>> >>> Briefly, if I have this in my XSLT: >>> >>> <xsl:text> </xsl:text> >>> >>> (the common way to get a space character in my result) >>> >>> I get nothing, and this >>> >>> <xsl:text> Boo! </xsl:text> >>> >>> gets me "Boo!" (leading and trailing whitespace trimmed). >>> >>> But I can't duplicate this behavior running BaseX from the GUI. >>> >>> I am sure there is a 'trim' or 'chop' setting somewhere that is >>> allowing this, but I don't know where to look. >>> >>> Any ideas? >>> >>> Thanks, Wendell >>> >>> -- >>> Wendell Piez | http://www.wendellpiez.com >>> XML | XSLT | electronic publishing >>> Eat Your Vegetables >>> _____oo_________o_o___ooooo____ooooooo_^ >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> >> >> >> -- >> Dirk Kirsten, BaseX GmbH, http://basex.org >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >> | Dr. Christian Grün, Alexander Holupirek, Michael Seiferle >> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22 > > > > -- > Wendell Piez | http://www.wendellpiez.com > XML | XSLT | electronic publishing > Eat Your Vegetables > _____oo_________o_o___ooooo____ooooooo_^ > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Hi Wendell,
as Dirk indicated, you may locally reset the CHOP value [1]:
return (# db:chop "no" #) {
xslt:transform($xml,$xslt)
}Hope this helps,
Christian
[1] http://docs.basex.org/wiki/Options
Quoted text · Wendell Piez · 145 lines
On Fri, Mar 1, 2013 at 3:18 PM, Wendell Piez <wapiez at wendellpiez.com> wrote: > Hi Christian, > > Sure, try this: > > declare %restxq:path("xslt-ws") > %output:method("xml") > function wap:xslt-ws() { > > let $xml := <test/> > let $xslt := > <xsl:stylesheet version='2.0' > xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> > > <xsl:template match="/"> > <html> > <body> > <h1> > <xsl:text>What </xsl:text> > <span>have </span> > <xsl:text>we </xsl:text> > <span>here? </span> > </h1> > <p>Transforming with <xsl:value-of > select="system-property('xsl:vendor')"/></p> > </body> > </html> > </xsl:template> > > </xsl:stylesheet> > > return xslt:transform($xml,$xslt) > }; > > Very interesting, too: I had some trouble at first reproducing the > error -- when I made this dummy mockup, at first, restxq behaved > correctly. I wondered whether it was a difference between xml and > xhtml serialization, but then the symptom reappeared with either one. > > Could some sort of caching be the culprit? > > Thanks, Wendell > > On Fri, Mar 1, 2013 at 5:42 AM, Christian Grün > <christian.gruen at gmail.com> wrote: >> Hi Wendell, >> >> do you have a little code snippet that allows us reproduce the problem? >> >> Best, >> Christian >> ___________________________ >> >> On Thu, Feb 28, 2013 at 9:05 PM, Wendell Piez <wapiez at wendellpiez.com> wrote: >>> Hi again, >>> >>> Sorry if I wasn't clear enough. The XSLT is not in the database; it is >>> called from the file system. >>> >>> I just checked, and I'm seeing the same behavior whether the database >>> is created with 'chop' on or off. Again, this under RESTXQ; when >>> calling the same XSLT from the GUI, everything is fine. >>> >>> Cheers, Wendell >>> >>> >>> >>> On Thu, Feb 28, 2013 at 12:18 PM, Dirk Kirsten <dk at basex.org> wrote: >>>> Hello, >>>> >>>> Please take a look at the CHOP database option, I guess that will fix it: >>>> http://docs.basex.org/wiki/Options#CHOP >>>> >>>> Cheers, >>>> Dirk >>>> >>>> >>>> On Thu, Feb 28, 2013 at 5:49 PM, Wendell Piez <wapiez at wendellpiez.com> >>>> wrote: >>>>> >>>>> Friends, >>>>> >>>>> I am encountering an odd whitespace-handling anomaly in BaseX when >>>>> invoking Saxon to transform files behind RESTXQ. >>>>> >>>>> Briefly, if I have this in my XSLT: >>>>> >>>>> <xsl:text> </xsl:text> >>>>> >>>>> (the common way to get a space character in my result) >>>>> >>>>> I get nothing, and this >>>>> >>>>> <xsl:text> Boo! </xsl:text> >>>>> >>>>> gets me "Boo!" (leading and trailing whitespace trimmed). >>>>> >>>>> But I can't duplicate this behavior running BaseX from the GUI. >>>>> >>>>> I am sure there is a 'trim' or 'chop' setting somewhere that is >>>>> allowing this, but I don't know where to look. >>>>> >>>>> Any ideas? >>>>> >>>>> Thanks, Wendell >>>>> >>>>> -- >>>>> Wendell Piez | http://www.wendellpiez.com >>>>> XML | XSLT | electronic publishing >>>>> Eat Your Vegetables >>>>> _____oo_________o_o___ooooo____ooooooo_^ >>>>> _______________________________________________ >>>>> BaseX-Talk mailing list >>>>> BaseX-Talk at mailman.uni-konstanz.de >>>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>>> >>>> >>>> >>>> >>>> -- >>>> Dirk Kirsten, BaseX GmbH, http://basex.org >>>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>>> | Dr. Christian Grün, Alexander Holupirek, Michael Seiferle >>>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22 >>> >>> >>> >>> -- >>> Wendell Piez | http://www.wendellpiez.com >>> XML | XSLT | electronic publishing >>> Eat Your Vegetables >>> _____oo_________o_o___ooooo____ooooooo_^ >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > -- > Wendell Piez | http://www.wendellpiez.com > XML | XSLT | electronic publishing > Eat Your Vegetables > _____oo_________o_o___ooooo____ooooooo_^
WP
Hi Christian,
Sure, try this:
declare %restxq:path("xslt-ws")
%output:method("xml")
function wap:xslt-ws() {
let $xml := <test/>
let $xslt :=
<xsl:stylesheet version='2.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<html>
<body>
<h1>
<xsl:text>What </xsl:text>
<span>have </span>
<xsl:text>we </xsl:text>
<span>here? </span>
</h1>
<p>Transforming with <xsl:value-of
select="system-property('xsl:vendor')"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
return xslt:transform($xml,$xslt)
};Very interesting, too: I had some trouble at first reproducing the error -- when I made this dummy mockup, at first, restxq behaved correctly. I wondered whether it was a difference between xml and xhtml serialization, but then the symptom reappeared with either one.
Could some sort of caching be the culprit?
Thanks, Wendell
Quoted text · Christian Grün · 94 lines
On Fri, Mar 1, 2013 at 5:42 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Wendell, > > do you have a little code snippet that allows us reproduce the problem? > > Best, > Christian > ___________________________ > > On Thu, Feb 28, 2013 at 9:05 PM, Wendell Piez <wapiez at wendellpiez.com> wrote: >> Hi again, >> >> Sorry if I wasn't clear enough. The XSLT is not in the database; it is >> called from the file system. >> >> I just checked, and I'm seeing the same behavior whether the database >> is created with 'chop' on or off. Again, this under RESTXQ; when >> calling the same XSLT from the GUI, everything is fine. >> >> Cheers, Wendell >> >> >> >> On Thu, Feb 28, 2013 at 12:18 PM, Dirk Kirsten <dk at basex.org> wrote: >>> Hello, >>> >>> Please take a look at the CHOP database option, I guess that will fix it: >>> http://docs.basex.org/wiki/Options#CHOP >>> >>> Cheers, >>> Dirk >>> >>> >>> On Thu, Feb 28, 2013 at 5:49 PM, Wendell Piez <wapiez at wendellpiez.com> >>> wrote: >>>> >>>> Friends, >>>> >>>> I am encountering an odd whitespace-handling anomaly in BaseX when >>>> invoking Saxon to transform files behind RESTXQ. >>>> >>>> Briefly, if I have this in my XSLT: >>>> >>>> <xsl:text> </xsl:text> >>>> >>>> (the common way to get a space character in my result) >>>> >>>> I get nothing, and this >>>> >>>> <xsl:text> Boo! </xsl:text> >>>> >>>> gets me "Boo!" (leading and trailing whitespace trimmed). >>>> >>>> But I can't duplicate this behavior running BaseX from the GUI. >>>> >>>> I am sure there is a 'trim' or 'chop' setting somewhere that is >>>> allowing this, but I don't know where to look. >>>> >>>> Any ideas? >>>> >>>> Thanks, Wendell >>>> >>>> -- >>>> Wendell Piez | http://www.wendellpiez.com >>>> XML | XSLT | electronic publishing >>>> Eat Your Vegetables >>>> _____oo_________o_o___ooooo____ooooooo_^ >>>> _______________________________________________ >>>> BaseX-Talk mailing list >>>> BaseX-Talk at mailman.uni-konstanz.de >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >>> >>> >>> >>> -- >>> Dirk Kirsten, BaseX GmbH, http://basex.org >>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>> | Dr. Christian Grün, Alexander Holupirek, Michael Seiferle >>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22 >> >> >> >> -- >> Wendell Piez | http://www.wendellpiez.com >> XML | XSLT | electronic publishing >> Eat Your Vegetables >> _____oo_________o_o___ooooo____ooooooo_^ >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
--
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
WP
Christian,
Ah, I missed this syntax, thanks! It's exactly what I need.
Another problem down.
If I might suggest -- for us XSLT folks it would be a huge favor to offer this hint at http://docs.basex.org/wiki/XSLT. As I keep stressing, we document folks are constantly having to fuss with whitespace and this is an important detail when using XSLT. (Which, I'm finding, is a huge power feature on top of XQuery.)
Cheers, Wendell
Quoted text · Christian Grün · 161 lines
On Fri, Mar 1, 2013 at 9:25 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Wendell, > > as Dirk indicated, you may locally reset the CHOP value [1]: > > return (# db:chop "no" #) { > xslt:transform($xml,$xslt) > } > > Hope this helps, > Christian > > [1] http://docs.basex.org/wiki/Options > ___________________________ > > On Fri, Mar 1, 2013 at 3:18 PM, Wendell Piez <wapiez at wendellpiez.com> wrote: >> Hi Christian, >> >> Sure, try this: >> >> declare %restxq:path("xslt-ws") >> %output:method("xml") >> function wap:xslt-ws() { >> >> let $xml := <test/> >> let $xslt := >> <xsl:stylesheet version='2.0' >> xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> >> >> <xsl:template match="/"> >> <html> >> <body> >> <h1> >> <xsl:text>What </xsl:text> >> <span>have </span> >> <xsl:text>we </xsl:text> >> <span>here? </span> >> </h1> >> <p>Transforming with <xsl:value-of >> select="system-property('xsl:vendor')"/></p> >> </body> >> </html> >> </xsl:template> >> >> </xsl:stylesheet> >> >> return xslt:transform($xml,$xslt) >> }; >> >> Very interesting, too: I had some trouble at first reproducing the >> error -- when I made this dummy mockup, at first, restxq behaved >> correctly. I wondered whether it was a difference between xml and >> xhtml serialization, but then the symptom reappeared with either one. >> >> Could some sort of caching be the culprit? >> >> Thanks, Wendell >> >> On Fri, Mar 1, 2013 at 5:42 AM, Christian Grün >> <christian.gruen at gmail.com> wrote: >>> Hi Wendell, >>> >>> do you have a little code snippet that allows us reproduce the problem? >>> >>> Best, >>> Christian >>> ___________________________ >>> >>> On Thu, Feb 28, 2013 at 9:05 PM, Wendell Piez <wapiez at wendellpiez.com> wrote: >>>> Hi again, >>>> >>>> Sorry if I wasn't clear enough. The XSLT is not in the database; it is >>>> called from the file system. >>>> >>>> I just checked, and I'm seeing the same behavior whether the database >>>> is created with 'chop' on or off. Again, this under RESTXQ; when >>>> calling the same XSLT from the GUI, everything is fine. >>>> >>>> Cheers, Wendell >>>> >>>> >>>> >>>> On Thu, Feb 28, 2013 at 12:18 PM, Dirk Kirsten <dk at basex.org> wrote: >>>>> Hello, >>>>> >>>>> Please take a look at the CHOP database option, I guess that will fix it: >>>>> http://docs.basex.org/wiki/Options#CHOP >>>>> >>>>> Cheers, >>>>> Dirk >>>>> >>>>> >>>>> On Thu, Feb 28, 2013 at 5:49 PM, Wendell Piez <wapiez at wendellpiez.com> >>>>> wrote: >>>>>> >>>>>> Friends, >>>>>> >>>>>> I am encountering an odd whitespace-handling anomaly in BaseX when >>>>>> invoking Saxon to transform files behind RESTXQ. >>>>>> >>>>>> Briefly, if I have this in my XSLT: >>>>>> >>>>>> <xsl:text> </xsl:text> >>>>>> >>>>>> (the common way to get a space character in my result) >>>>>> >>>>>> I get nothing, and this >>>>>> >>>>>> <xsl:text> Boo! </xsl:text> >>>>>> >>>>>> gets me "Boo!" (leading and trailing whitespace trimmed). >>>>>> >>>>>> But I can't duplicate this behavior running BaseX from the GUI. >>>>>> >>>>>> I am sure there is a 'trim' or 'chop' setting somewhere that is >>>>>> allowing this, but I don't know where to look. >>>>>> >>>>>> Any ideas? >>>>>> >>>>>> Thanks, Wendell >>>>>> >>>>>> -- >>>>>> Wendell Piez | http://www.wendellpiez.com >>>>>> XML | XSLT | electronic publishing >>>>>> Eat Your Vegetables >>>>>> _____oo_________o_o___ooooo____ooooooo_^ >>>>>> _______________________________________________ >>>>>> BaseX-Talk mailing list >>>>>> BaseX-Talk at mailman.uni-konstanz.de >>>>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Dirk Kirsten, BaseX GmbH, http://basex.org >>>>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>>>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>>>> | Dr. Christian Grün, Alexander Holupirek, Michael Seiferle >>>>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22 >>>> >>>> >>>> >>>> -- >>>> Wendell Piez | http://www.wendellpiez.com >>>> XML | XSLT | electronic publishing >>>> Eat Your Vegetables >>>> _____oo_________o_o___ooooo____ooooooo_^ >>>> _______________________________________________ >>>> BaseX-Talk mailing list >>>> BaseX-Talk at mailman.uni-konstanz.de >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> >> >> -- >> Wendell Piez | http://www.wendellpiez.com >> XML | XSLT | electronic publishing >> Eat Your Vegetables >> _____oo_________o_o___ooooo____ooooooo_^
--
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
Written for BaseX 7.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery