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

Re: copy-of question

Subject: Re: copy-of question
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 19 Apr 2001 08:28:25 +0100
xsl copy unmatched
Hi Franz,

> Yes. The default rules gives the unmatched elements back as
> unformattet text I guess. Coult You give me an example to extract
> only an element out of a huge xml?

Well, you can either approach it from a pull direction or a push
direction.

If you want to pull, then you should find an XPath that identifies the
single node that you want to copy from the root node of the tree,
perhaps through id() or by stepping down to it. I don't know what your
XML looks like, unfortunately, so I can only say that:

  //TABLE

will work to point at the TABLE element in your XML.  There may be a
much better path - this one is far from optimal because it uses the
descendant-or-self:: axis, which is very inefficient.

Then you should have a single template that operates very near the top
of the tree (often the root node), and that copies only this one node:

<xsl:template match="/">
   <xsl:copy-of select="//TABLE" />
</xsl:template>

The push method would involve changing the default templates.  To get
no output by default, you only need to change the template that
matches text() nodes, making it do nothing rather than giving the
value of the text.  So just add the template:

<xsl:template match="text()" />

to your current stylesheet.

Which one is most efficient depends on the structure of your XML, the
processor you're using and whether you can come up with a better XPath
to access the node you're interested in.  Generally I'd go for pull in
this situation.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.