[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: A sequence of more than one item is not allowed as
In summary then, when building a string in a variable and you want to avoid document node creation it's preferable to use item()+ than xs:string+ as that allows the merging of adjacent text nodes before atomization, creating a sequence of one item therefore bypassing the separator issue? well yes or no. If you want to build a (sequence of) string(s) in a variable then you have to use xs:string+ as otherwise you will get other things in your sequence (like nodes). Sometimes you don't need to worry about the difference between a string and a text node, but somethimes you do (as you've demonstrated). In general the distinction is far more important in 2.0 than 1.0. So, if you want a sequence of strings use xsd:string and use separator="" on a value-of if you don't want the spaces. If you want a sequence of nodes and/or strings use item()+ (but personally if I knew there was a possibility of adding an unwanted space I'd just always add separator="" rather than run through the six point simple content construct in my head every time to see if the spaces wouldn't be added) If you just want to use the thing as a string, and don't want spaces, and don't want to worry about any of this stuff then just use the xsl 1.0 version without an as attribute at all. there is the extra overhead that you are generating a document node, but since you are also generating new nodes in the as="item()+" version then this probably isn't really so expensive (unless Michael says otherwise:-) David <xsl:variable name="foo" as="item()+"> <xsl:text>abc</xsl:text><xsl:value-of select="'def'"/> </xsl:variable> <xsl:template match="/"> <xsl:value-of select="$foo"/> </xsl:template> Gives the required 'abcdef' <xsl:variable name="foo" as="xs:string+"> <xsl:text>abc</xsl:text><xsl:value-of select="'def'"/> </xsl:variable> <xsl:template match="/"> <xsl:value-of select="$foo"/> </xsl:template> Gives the unwanted 'abc def' Hmmmmmmm... ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
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
|