Subject: Re: [xsl] 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 |
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&style=dynaxml.xsl<xsl:text>&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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] finding the parent id of an e, Cindy Mazza | Thread | [xsl] xsl <xsl:template match= ques, dmitri kerievsky |
[xsl] Problems calling template fro, Ryan . Kelly | Date | Re: [xsl] Problems calling template, David Carlisle |
Month |