This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
finding the parent id of an element in an external XML document
- From: Cindy Mazza <clm6u at virginia dot edu>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 14 Jun 2002 09:30:21 -0400
- Subject: [xsl] finding the parent id of an element in an external XML document
- Organization: IATH
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
I'm trying to resolve an external cross-reference, but I want to
display (by chunking up) the division ancestor element and all its contents.
So I know the document, and I know the cross referenced id - I need to
find the id of its ancestor that is a div3. (dont' know how clear that
was)
Here's the XML involved:
-----------
(main doc) lz.xml
-----------
<xref doc="odes" from="l.09" to="l.10">Book of Odes</xref>
-----------
(supporting doc) odes.xml
-----------
<TEI.2 id="odes">
....
<div3 id="d3.27">
<head>LIE WEN</head>
<lg>
<l>...</l>
<l id="l.09">What is most distinguished is being virtuous ; --</l>
<l id="l.10">It will secure the imitation of all the princes .</l>
<l>...</l>
</lg>
</div3>
...
</TEI.2>
-----------
I have the following XSLT:
<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&style=dynaxml.xsl<xsl:text>&chunk.id=</xsl:text>
<xsl:choose>
<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>
$dvid
</xsl:when>
<xsl:otherwise>
<!-- ... -->
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</a></i>
</xsl:template>
-----------
I can't get the variable dvid to resolve. I know I'm missing something
really simple here, but I'm new to XSLT and am having problems
figuring it out.
Any help would be great.
Thanks,
-----
- Cindy
Cynthia L. Mazza
mailto:clm6u@virginia.edu
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list