[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] when to use 'as' attribute on a variable
Subject: Re: [xsl] when to use 'as' attribute on a variable From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 8 Mar 2006 13:58:34 GMT |
> So what advantage does document-node() give me over element(), node(), or > item()?? if the value of the variable is a document node (called a root node in xpath 1) then typing it as document-node() will work, but declaring it as element() would generate an error (as document nodes are not elements). You could declare it as node() or item() and it would work but essentially that's just turning off type checking, it's like declaring everything in java to be Object; it's true, but loses most of the benefits of having a type system. (Of course not everyone agrees that having strict typing in XPath is a benefit, so XSLT is designed to work pretty well if everything has such a general declared type (and that's essentially the default behaviour if you don't declare types) > In XPath 1 <xsl:value-of select="node()"/> would return the value of the > text nodes - presumably the node() you are referring to is a completely > different data type and unrelated? node() in Xpath (1 and 2) is a node test and used in that context it _selects_ any node. I'm not sure why you say "_text_ nodes" in the above. node() matches all nodes (including text, elements, comments, etc) this is unchanged in XPath 2. Here we are talking about sequence types (as=".." attributes in xslt2) although some of the syntax looks similar to XPath, the meaning is completely different. This is most noticable for atomic types. If you have select="xs:integer" then that is an XPath and selects _element_ nodes, eg <xs:integer/>. If on the other hand you have as="xs:integer" that is specifying that the type of the value being declared is an _integer_, eg 10. David ________________________________________________________________________ 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] when to use 'as' attribut, tom tom | Thread | Re: [xsl] when to use 'as' attribut, Florent Georges |
AW: [xsl] Stylesheet for converting, Huditsch, Roman \(LN | Date | Re: [xsl] when to use 'as' attribut, Florent Georges |
Month |