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

hooray

Subject: hooray
From: S Woodside <sbwoodside@xxxxxxxxx>
Date: Tue, 25 Mar 2003 01:55:07 -0500
 hooray
I finally figured out how to do something that's been bugging me for ages.

I wanted to have two input documents, one is RNG and it defines the structure of a document. The other one is an instance document. I want to determine a path from the RNG (relax NG) and see if there's an instance value for it in the instance document.

<xsl:template name="InstanceValue">
<xsl:variable name="instPathStr">
<xsl:for-each select="current()/ancestor-or-self::*[@name]">
<xsl:text>/</xsl:text>
<xsl:value-of select="@name"/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="document('inst.xml')">
<xsl:if test="not(dyn:evaluate($instPathStr)/*)">
<prefilled-path><xsl:value-of select="$instPathStr"/></prefilled-path>
<prefilled-value>
<xsl:value-of select="dyn:evaluate($instPathStr)"/>
</prefilled-value>
</xsl:if>
</xsl:for-each>
</xsl:template>


I make use of several non-obvious things in this (IMHO!) although maybe it could be improved further. First, I used a for-each select=document('inst.xml') because you're not allowed to do ... well, I had the document in a variable actually and you can't do $variable/$var2 ... grr! Also, you'll note that instPathStr gets created as a string and then I use dyn:evaluate to turn it back into a node set inside the document context! That's because if I made a node-set in the variable it would implicitly be in the source document (the RNG) instead of in the inst.xml (right?!)

I'd love to know if there's any better ways to do this ... but it works :-D

simon


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



Current Thread
  • hooray
    • S Woodside - Tue, 25 Mar 2003 01:51:23 -0500 (EST) <=

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.