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

Re: finding the parent id of an element in an external

Subject: Re: finding the parent id of an element in an external XML document
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 14 Jun 2002 14:53:49 +0100
parent id
Apart from your problem with the particular functions document(0 and
id() your main problem is that you are writing XPath expressions
as character data of the stykesheet. that _never_ works for
any expression, XPath as used in XSLT always appears in an attribute.



        <xsl:when test="@from">
             <xsl:variable name="dvid">document('../texts/<xsl:value-of select="@doc"/>.xml')//id(@from)/ancestor-or-self::div3[1]/@id</xsl:variable>


So that makes a variable with text nodes containing "document" (and
other stuff) but that is just character data the system will never see
it as an expression to be evaluated.


similarly this is just the characters $divd it does not denote a
reference to the variable unless you put it in an attribute such as 
<xsl:value-of  select="$divid"/>


             $dvid

I think you just want

<xsl:template match="xref">
   <i><a target="new">
     <xsl:attribute name="href">
       <xsl:text>http://localhost:8080/saxon/servlet/SaxonServlet?source=</xsl:text>
       <xsl:value-of select="@doc"/>.xml&#038;style=dynaxml.xsl<xsl:text>&#038;chunk.id=</xsl:text>
       <xsl:choose>
          <xsl:when test="@from">
              <xsl:variable name="from" select="@from"/>
             <xsl:for-each select="document(concat(../texts/@doc,'.xml'))">
              <xsl:value-of select="id($from)/ancestor-or-self::div3[1]/@id"/>
             </xsl:for-each>
          </xsl:when>
          <xsl:otherwise>
                <!-- ... -->
          </xsl:otherwise>
       </xsl:choose>
     </xsl:attribute>
     <xsl:apply-templates/>
   </a></i>
</xsl:template>

howeverthis assumes that both your documents have a <!DOCTYPE that
specifies that the attributes are of type ID otherwise id() will never
find anything.

You may be better to use keys.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 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.