Subject: RE: [xsl] preserve-space and strip-space? From: "Zwetselaar M. van (Marco)" <Marco.van.Zwetselaar@xxxxxxxxxxxxx> Date: Mon, 17 Sep 2001 15:16:38 +0200 |
Whitespace-stripping (see XSLT Spec section 3.4) is not about stripping any whitespace, it is about stripping text nodes that contain only whitespace. Marco > -----Oorspronkelijk bericht----- > Van: Kirk Allen Evans [mailto:kaevans@xxxxxxxxx] > Verzonden: Monday, 17 September, 2001 14:29 > Aan: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Onderwerp: [xsl] preserve-space and strip-space? > > > Maybe I am wrong on what strip-space and preserve-space are > supposed to do. > Using the following XML document, I pad each element's values > with spaces. > > <?xml version="1.0" encoding="UTF-8" ?> > <links> > <link> testing pre-stripping</link> > <link>testing post-stripping </link> > <link> testing any stripping </link> > </links> > > Then, applying the stylesheet, I specify the "link" element is to be > stripped. > > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:strip-space elements="link" /> > <xsl:template match="/"> > <xsl:for-each select="links/link"> > <xsl:text>[</xsl:text> > <xsl:value-of select="." /> > <xsl:text>]</xsl:text> > </xsl:for-each> > </xsl:template> > </xsl:stylesheet> > > I would expect the result as > <?xml version="1.0" encoding="UTF-16"?>[testing pre-stripping][testing > post-stripping][testing any stripping] > > Instead, the result is > <?xml version="1.0" encoding="UTF-16"?>[ testing > pre-stripping][testing > post-stripping ][ testing any stripping ] > > If stripping does not affect the elements' values, then what does the > whitespace preserve and stripping preserve or strip? I > thought that it > might be whitespace within the tag delimiters, so I used the > following XML > doc. > > <?xml version="1.0" encoding="UTF-8" ?> > <links> > <link > testing pre-stripping</link > > <link >testing post-stripping </link > > <link > testing any stripping </link > > </links> > > The following stylesheet explicitly preserves space, but > seems to have no > effect. > > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:preserve-space elements="link" /> > <xsl:template match="/"> > <xsl:apply-templates /> > </xsl:template> > <xsl:template match="@* | node()"> > <xsl:copy> > <xsl:apply-templates select="@* | node()" /> > </xsl:copy> > </xsl:template> > </xsl:stylesheet> > > > The result of this transformation is the same as the input, > but the space > within the element tags is gone, so preserve-space had no > noticeable effect > here. > > <?xml version="1.0" encoding="UTF-16"?><links> > <link> testing pre-stripping</link> > <link>testing post-stripping </link> > <link> testing any stripping </link> > </links> > > -- > Kirk Allen Evans > http://www.vbdna.net/rant > > God bless the USA > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > ***************************DISCLAIMER*********************************** Deze e-mail is uitsluitend bestemd voor de geadresseerde(n). Verstrekking aan en gebruik door anderen is niet toegestaan. Fortis sluit iedere aansprakelijkheid uit die voortvloeit uit electronische verzending. This e-mail is intended exclusively for the addressee(s), and may not be passed on to, or made available for use by any person other than the addressee(s). Fortis rules out any and every liability resulting from any electronic transmission. ************************************************************************ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Union of two node-sets no, Michael Kay | Thread | Re: [xsl] preserve-space and strip-, Kirk Allen Evans |
RE: [xsl] Non-existing node, Michael Kay | Date | RE: [xsl] outputing elements correc, Michael Kay |
Month |