[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Select entire XML doc

Subject: RE: Select entire XML doc
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Mon, 3 Mar 2003 17:04:58 -0600
xsl select copy original node
[Brian Martinez wrote:]

> > > <xsl:template match="/">
> > >   <textarea>
> > >     <xsl:copy-of select="*"/>
> > >   </textarea>
> > > </xsl:template>
> >
> > From: Lars Huttar
> > 
> > Just out of curiosity, and because I'm learning:
> > Wouldn't the above copy-of fail to copy any non-element 
> > children of the
> > root node?  E.g. comments and PI's...
> > (He did say "the entire XML document.")
> 
> No.  If the comments and PIs (by that I assume you mean processing
> instructions) are children of the root or context node, 
> xsl:copy-of will
> write them to the result tree.
> 
> cheers,
> b.

What I meant was that because your <xsl:copy-of> used select="*",
it would only operate on element children of the root node.
So comments/PIs would only be copied if they were descendants
of the document node, not if they were children of "/".

I tried this with a sample document, and sure enough, top-level
comments and processing instructions were lost.  That may not
matter to the original poster but I just wanted to make sure I
was understanding right.

 <?xml version="1.0"?>
 <?xml-stylesheet type="text/xsl" href="test-select.xsl"?>

 <!-- This comment is lost. -->
 <doc>The document node.
   <child>A child node.</child>
 </doc>

 <!-- Another pesky comment. -->
 <?pi r squared but we dont care?>


The output from your template:

  <textarea><doc>The document node.
    <child>A child node.</child>
  </doc></textarea>

Regards,
Lars


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.