Subject: Re: [xsl] Selecting unparsed text from inside a tag From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 25 Mar 2008 21:35:18 GMT |
> I said I sometimes use xsl:sequence (instead of value-of, copy-of, > apply-templates) and wondered if there might be side effects to using > xsl:sequence for this purpose that I may not know about.... If you are going to the result tree then xsl:sequence and xsl:copy-of are the same thing for that use, but if it is the result of a template or function being save in a varuiable then they are different, using copy-of you get new (parentless) nodes that are copies of the original nodes, using xsl:sequence references the original nodes in the document. This can make a lot of difference, which you need depends on what you want to do. So if the input is <x><a/><b/><c/></x> and you do <xsl:variable name="v1" as="node()*"> <xsl:copy-of select="x/node()"/> </xsl:variable> <xsl:variable name="v2" as="node()*"> <xsl:sequence select="x/node()"/> </xsl:variable> Then if you copy either $v1 or $v2 to the result tree you get <a/><b/><c/> but for example $v1[1]/following-sibling::* is <b/><c/> as they are the following siblings of <a/> in the original document but $v2[1]/following-sibling::* is the empty sequence as $v2 consists of three new nodes <a/>, <b/>, <c/> with no common parent and unconnected by the sibling axis. It would be hard to guess that you meant the content of p in <p>Some text and <br/> some more <b>text</b>.</p> from the subject line as it is parsed and it is not the content of a tag. An XML parser parses the entire source document before XSLt sees any of the input, and there are 5 tags in the above with contents p, br, b, b and p. Element content is marked up _between_ two tags, it isn't the content of either of them. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Selecting unparsed text f, Angela Williams | Thread | [xsl] XSLT 2.0 in a web browser, Colin Adams |
Re: [xsl] XSLT 2.0 in a web browser, bryan rasmussen | Date | RE: [xsl] how to match elements in , Michael Kay |
Month |