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

RE: How Do I Select A Section of XML Based On A Code V

Subject: RE: How Do I Select A Section of XML Based On A Code Value
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Wed, 25 Feb 2004 10:38:20 -0500
select section of xml
Something like this:


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
	<xsl:for-each select="//VehInfo[descendant::UsageInfoCode =
'Work']">
		<xsl:element name="VehInfo">
			<xsl:element name="ModelYear">
				<xsl:value-of select="ModelYear"/>
			</xsl:element>
			<xsl:element name="Model">
				<xsl:value-of select="Model"/>
			</xsl:element>


		</xsl:element>
	</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Gary Fix
Sent: Wednesday, February 25, 2004 10:17 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  How Do I Select A Section of XML Based On A Code Value

Hi,
I have an xml something like this:

	<VehInfo>
		<ModelYear>2004</ModelYear>
		<Model>Ford</Model>
		<UsageInfo>
			<UsageInfoCode>Work</UsageInfoCode>
		</UsageInfo>
	</VehInfo>
	<VehInfo>
		<ModelYear>1994</ModelYear>
		<Model>Toyota</Model>
		<UsageInfo>
			<UsageInfoCode>Pleasure</UsageInfoCode>
		</UsageInfo>
	</VehInfo>

and want to transform this into xml using xsl, selecting the correct section
based on the <UsageInfoCode> tag. For example, if I am to select using an
"UsageInfoCode" of "Work", then I want the output xml to look like this:

	<VehInfo>
		<ModelYear>2004</ModelYear>
		<Model>Ford</Model>
	</VehInfo>

Any help would be greatly appreciated!
thanks....gary...

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 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.