|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: attribute management
Hi Brian, > I've run into some difficulty attempting to define an attribute. > Essentially, I'm getting excess spaces, and I'd really like them > removed while keeping the formatting the same for readability. Below > is a sample xml and xslt. > > XSLT: > > <xsl:template name="uri"> > <xsl:attribute name="background"> > <xsl:choose> [snip] > </xsl:choose>/ > > <xsl:choose> [snip] > </xsl:choose>. > > <xsl:choose> [snip] > </xsl:choose> > </xsl:attribute> > </xsl:template> In the above XSLT, you're inserting a bunch of whitespace after the / and the . in your attribute value. Presumably this is the whitespace that you want to get rid of? In XSLT, any text that contains any non-whitespace character is added to the result. In the above, you're not only adding the /, you're also adding the line breaks after it and the indentation prior to the next <xsl:choose>. To limit the whitespace that you add, you should wrap the non-whitespace characters within <xsl:text> elements: <xsl:template name="uri"> <xsl:attribute name="background"> <xsl:choose> ... </xsl:choose> <xsl:text>/</xsl:text> <xsl:choose> ... </xsl:choose> <xsl:text>.</xsl:text> <xsl:choose> ... </xsl:choose> </xsl:attribute> </xsl:template> The <xsl:text> elements separate the characters you're interested in from the (ignorable) whitespace that follows them. The whitespace-only text nodes get ignored. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






