xsl-list
[Top] [All Lists]

Re: [xsl] XSLT2 processing question

2006-05-23 09:43:11

What am I doing wrong? I thought the stylesheet would do the
following: Go to the root element (match="/"),

No. / never matches an element it is the root node (in XPath 1) or teh
document node (new name for same thing in XPath 2) which is the parent
of the top level element (and also teh parent of top level comments and
processing instructions.

generate my root ("adress") 
In XSLT1 you can not explictly create a root node, it is created
implictly when you insert a top level element (or text or comment or
processing instruction) into teh result tree. XSLT2 does have an explict
xsl:document instruction to generate document nodes when needed (which
is not very often).

 The next template searches for the node "name"
everyware in the source ("//name"),

The existence of a template never causes anything to be searched, that
is controlled by eth select attribute on apply-templates. The match
attribute just says that this template is to be invoked if the nodes
that are selected match. (Starting a match with // does not change the
nodes matched in XSLT1, it just changes the default priority).

As others have said the result you get is because of the default
template for elements, and the fact that the default select attribute on
apply-templates is select="node()" ie select all children.

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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>