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

RE: XSLT to query/output a portion of an XML source d

Subject: RE: XSLT to query/output a portion of an XML source document
From: "Houghton,Andrew" <houghtoa@xxxxxxxx>
Date: Wed, 24 Jan 2007 15:39:37 -0500
RE:  XSLT to query/output a portion of an XML source  d
Why not just:

<xsl:copy-of
select="//DataService/Transaction/Response/MasterCatalogRecord/EntityData[../
ExternalKeys/Key[1] = '2' and ../ExternalKeys/Key[2] = 'b']"/>

No need for a xsl:for-each.


Andy.

> -----Original Message-----
> From: Chris Coyle [mailto:chriscoyle@xxxxxxxxx]
> Sent: 24 January, 2007 14:51
> To: Mullberytech.com
> Subject:  XSLT to query/output a portion of an XML
> source document
>
>
>
> I need to write a query to pull 1 node out of a source XML document.
>
> The source document has a structure of
>
> <Transaction>
> 	<Response>
> 		<MasterCatalogResponse>
> 			<ExternalKeys>
> 				<Key>1</Key>
> 				<Key>a</Key>
> 			</ExternalKeys>
> 				<EntityData>
> 					<Attribute>a</Attribute>
> 					<Attribute>b</Attribute>
> 				</EntityData>
> 		</MasterCatalogRecord>
> 		<MasterCatalogResponse>
> 			<ExternalKeys>
> 				<Key>2</Key>
> 				<Key>b</Key>
> 			</ExternalKeys>
> 				<EntityData>
> 					<Attribute>a</Attribute>
> 					<Attribute>b</Attribute>
> 				</EntityData>
> 		</MasterCatalogRecord>
> 		<MasterCatalogResponse>
> 			<ExternalKeys>
> 				<Key>3</Key>
> 				<Key>c</Key>
> 			</ExternalKeys>
> 				<EntityData>
> 					<Attribute>a</Attribute>
> 					<Attribute>b</Attribute>
> 				</EntityData>
> 		</MasterCatalogRecord>
> 	</Response>
> </Transaction>
>
> I need to extract the <EntityData> element for a given
> <ExternalKeys> value match.  The result should look like this
> for an ExternalKeys  (2,b)
>
> 				<EntityData>
> 					<Attribute>a</Attribute>
> 					<Attribute>b</Attribute>
> 				</EntityData>
>
>
> This is what I tried:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?altova_samplexml SampleQueryResponse.xml?> <xsl:stylesheet
> version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:fn="http://www.w3.org/2005/xpath-functions">
>
>     <xsl:output method="xml" encoding="UTF-8"
> indent="yes" />
>
> <xsl:template match="/">
>    <xsl:for-each
> select="//DataService/Transaction/Response/MasterCatalogRecord">
> 	   <xsl:element name="EntityData">
> 		   <xsl:value-of select="."/>
> 	   </xsl:element>
>    </xsl:for-each>
>  </xsl:template>
>
> </xsl:stylesheet>
>
>
> Any suggestions are welcome.
>
>
>
>
>
>
> ______________________________________________________________
> ______________________
> Bored stiff? Loosen up...
> Download and play hundreds of games for free on Yahoo! Games.
> http://games.yahoo.com/games/front

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-2011 All Rights Reserved.