xsl:variable xsl:copy-of select
Posted
by
user1901345
on Stack Overflow
See other posts from Stack Overflow
or by user1901345
Published on 2012-12-13T17:01:53Z
Indexed on
2012/12/13
17:03 UTC
Read the original article
Hit count: 142
xslt
I have the following XML: Picture 1 Picture 2 Picture 3
While this XSL does what is expected (output the attr of the first picture):
It seems to be not possible to do the same inside the variable declaration using xsl:copy-of:
Curious: If I just select "$FirstPicture" instead of "$FirstPicture/@attr" in the second example, it outputs the text node of Picture 1 as expected...
Before you all suggest me to rewrite the code: This is just a simplified test, my real aim is to use a named template to select a node into the variable FirstPicture and reuse it for further selections.
I hope someone could help me to understand the behavior or could suggest me a proper way to select a node with code which could be easily reused (the decission which node is the first one is complex in my real application). Thanks.
© Stack Overflow or respective owner