[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] List of Unique Items within an XML Document


Subject: RE: [xsl] List of Unique Items within an XML Document
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Tue, 22 Jun 2004 10:57:37 -0400

>From what I see, the easiest thing for you to do would be to change your
productTemplate to match="Row". Then you would use xsl:apply-templates. Or
you could dor a for-each select="Row" within the import template, but the
match="Row" template would be nicer in this case.  I would write out an
example but my system crashed and lost my IDE yesterday.

-----Original Message-----
From: Ben Gazzard [mailto:BenG@xxxxxxxxxxxxxx] 
Sent: Tuesday, June 22, 2004 10:53 AM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: [xsl] List of Unique Items within an XML Document

Hi All,

Basically I have quite a flat XML Document that needs to be converted into a
more structured one.

----Original XML----

<?xml version="1.0" encoding="UTF-8"?>
<Import>
	<Row>
		<customer>ADULTS</customer>
		<product>SOCKS</product>
		<productID>611150</productID>
		<productName>COPA 3 STRIPE SOCK</productName>
		<productColor>WHITE/BLK</productColor>
		<productSize>2 | 3 | 4</productSize>
	</Row>
</Import>

----Converted XML----

<productCatalog>
<product type="STRIPED SOCK">
	<productName>STRIPED SOCK</productName>
	<productType>SOCKS</productType>
	<productSpecs>manual</productSpecs>
	<productSize>
		<sizeAdult>2 | 3 | 4</sizeAdult>
		<sizeKid></sizeKid>
	</productSize>
	<productPrice>
		<priceAdult>manual</priceAdult>
		<priceKid>manual</priceKid>
	</productPrice>
	<!-- Repeat for each colour variation -->
	<productInfo id="1" type="STRIPED SOCK">
		<productCode>
			<codeAdult>2134124</codeAdult>
			<codeKid></codeKid>
		</productCode>
		<productColorScheme>
			<colourDecsription>WHITE/BLK</colourDecsription>
			<colourCode>manual</colourCode>
			<colourCode>manual</colourCode>
		</productColorScheme>
	</productInfo>
</product>
<productCatalog>

The XSLT works fine so far. This Template triggers the other templates based
on the product param.

<xsl:template match="Import">
	<productCatalog>
		<xsl:call-template name="productTemplate">
			<xsl:with-param name="product" select="'COPA 3
STRIPE SOCK'"/>
		</xsl:call-template>
		<!-- repeated for each product -->
	</productCatalog>
</xsl:template>

What I want to happen is that instead of manually putting each product name
into a call-template param is for the xslt to do it itself. What is the best
way to do this?

Hope someone can help!

Cheers,
Ben


This e-mail and any attached files are for the exclusive use of the
addressee and may contain privileged and/or confidential information. If you
receive this e-mail in error you should not disclose the contents to any
other person nor take copies but should delete it and telephone us
immediately on +44(0)20 7557 6100.

TEQUILA\ London Limited does not make any warranty as to the accuracy or
completeness of this e-mail and we accept no liability for its content or
use. Any opinions expressed in this e-mail are those of the author and do
not necessarily reflect the opinions of TEQUILA\ London Limited.

TEQUILA\ London Limited operates within the parameters set by the Data
Protection Act 1998 with regard to the use of personal information including
e-mail addresses. We accept no liability for the forwarding of this e-mail
to other parties that may result in unsolicited e-mails being received by
those whose email addresses appear in this e-mail.

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--




Current Thread
Keywords