Subject: Re: [xsl] Trouble matching only elements with a specific combination of attributes in a child element. From: Joerg Heinicke <joerg.heinicke@xxxxxx> Date: Wed, 16 Oct 2002 22:35:45 +0200 |
> <xsl:template match="object[metadata/app_data/@name = 'Type' and > metadata/app_data/@value = 'RFI']">
Hello,
I have an xml file that is structured something like
<?xml version="1.0" encoding="UTF-8"?> <root> <object id="00125"> <metadata> <app_data name="Type" value="RFI"/> <app_data name="Version_Major" value="1"/> </metadata> </object> <object id="00126"> <metadata> <app_data name="Type" value="Video"/> <app_data name="Category" value="RFI"/> </metadata> </object> </root>
I am trying to build a style sheet that will match object elements that contain a child app_data element where the app_data element has a name of "Type" and a value of "RFI". Here is the style sheet I am trying to use. It has a problem that I cannot figure out. It matches any object that has any app_data with a name of "Type" and with any other app_data with a value of "RFI". As a result, both of the objects in my sample XML file are matched. I could use some help with creating the Xpath expression to matchin only the first object.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:element name="Assets"> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="object[metadata/app_data/@name = 'Type' and metadata/app_data/@value = 'RFI']"> <xsl:element name="Asset"> <xsl:value-of select="@id"/> </xsl:element> </xsl:template> </xsl:stylesheet>
Many thanks.
-- Bennett
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Trouble matching only element, Bennett Smith | Thread | Re: [xsl] Trouble matching only ele, J.Pietschmann |
[xsl] Trouble matching only element, Bennett Smith | Date | Re: [xsl] Trouble matching only ele, J.Pietschmann |
Month |