|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Trouble matching only elements with a specific combina
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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








