[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Trouble matching only elements with a specific combina

Subject: Trouble matching only elements with a specific combination of attributes in a child element.
From: "Bennett Smith" <bsmith@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Oct 2002 13:21:47 -0700
bennett smith
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.