[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
charlieo0@xxxxxxxxxxx wrote:
Define
<xsl:key name="el-by-id" match="*" use="@id"/>
(you might want to change the match attribute to a pattern listing those elements you are interested in, instead of matching on any elements with "*").
Then use
<xsl:template match="xref">
<xsl:value-of select="key('el-by-id', @taskid)/title"/>
</xsl:template>
--
Re: [xsl] Need to find element name of corresponding attribute value
Subject: Re: [xsl] Need to find element name of corresponding attribute value From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Fri, 15 Jul 2011 15:59:08 +0200 |
charlieo0@xxxxxxxxxxx wrote:
I need help finding a method for getting the name of an element based on the corresponding ID and IDREF attributes. I cannot use the id() function because the project I'm working is converting well-formed XML to DTD compliant XML. The id() function doesn't work because there is no DTD that defines ANY attribute types. So basically assume the ID attribute is defined as CDATA and not ID.
Here is basically what I'm working from:
<service id="M202-01"> <title>TITLE</title> <para>See<xref taskid="M202-02"/>.</para> <para>Stuff</para> </service> <remove id="M202-02"> <title>TITLE</title> <para>Para stuff</para> </remove>
I need to identify the name of the element that contains the ID value of the the "taskid" in<xref>. Once I have that, I can grab the value of the child<title> element.
Define
<xsl:key name="el-by-id" match="*" use="@id"/>
(you might want to change the match attribute to a pattern listing those elements you are interested in, instead of matching on any elements with "*").
Then use
<xsl:template match="xref">
<xsl:value-of select="key('el-by-id', @taskid)/title"/>
</xsl:template>
--
Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need to find element name, David Carlisle | Thread | [xsl] adjust width of block to prev, Mathis Mörke |
Re: [xsl] Need to find element name, David Carlisle | Date | [xsl] adjust width of block to prev, Mathis Mörke |
Month |