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

Re: document() and fragment

Subject: Re: document() and fragment
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Mon, 17 Dec 2001 11:27:31 +0200
Re:  document() and fragment
Brian Smith wrote:

Saxon 6.4.4 supports using a fragment identifier (bare name xpointer) with the document function like this: document("doc.xml#text"). This is very handy but it is causing me a problem with the way the resulting node-set is rooted.

Lets say I have this document, doc.xml (assume "id" is an ID attribute):

 <root>
   <package id="a1" name="javax">
       <package id="a2" name="swing">
          <package id="a3" name="text"/>
       </package>
   </package>
 </root>

Now, lets say I'm processing another document, and I evaluate the expression document("doc.xml#a3"). Saxon will return a node-set with a root node containing the package element with id "a3" ("text"). But, I need to traverse the ancestor:: axis in order to get the fully-qualified name of the package ("javax.swing.text"), such as by doing this:

<xsl:for-each select='document("doc.xml#text")/*
                                      /ancestor-or-self::package'>
     <xsl:value-of select='@name'/>
     <xsl:if test='position() != last()'>.</xsl:if>
</xsl:for-each>

Unfortunately, this doesn't work because the result of "document()" will be rooted at the "a3" node, not at the actual root of the doucment.

Is there any way around this? I wish the document() function behaved in a way that would allow me to access the ancestors and predecessors of the selected element.


So, if you want to see the whole document you can't only take a fragment.

What about this:
<xsl:for-each select='document("doc.xml")//package[@name="text"]
                                       /ancestor-or-self::package'>
      <xsl:value-of select='@name'/>
      <xsl:if test='position() != last()'>.</xsl:if>
</xsl:for-each>

--
Oleg Tkachenko
Multiconn International, Israel


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.