Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[RESOLVED] RE: Transform Xml w/ attributes...

From: den2005@-----------.---------.---
To: NULL
Date: 7/3/2006 7:41:00 PM

This exact problem has been resolved.

This works exactly what I wanted.

<xsl:template match="/">
	<Products>
		<xsl:for-each select="NewDataSet/Products">	
			<xsl:element name="Product">
				<xsl:attribute name="Name"><xsl:value-of 
select="ProductName"/></xsl:attribute>
				<xsl:attribute name="ID"><xsl:value-of 
select="ProductID"/></xsl:attribute>
				<UnitPrice><xsl:apply-templates select="UnitPrice" /></UnitPrice>
				<Quantity><xsl:apply-templates select="Quantity" /></Quantity>
				<ReorderLevel><xsl:apply-templates select="ReorderLevel" /></ReorderLevel>
			</xsl:element>			
		</xsl:for-each>
	</Products>	
</xsl:template>

den2005

-- 
MCP Year 2005, Philippines


"den 2005" wrote:

> Hi everybody,
> 
>    I need transform the xml file generated from dataset to a xml file with 2 
> columns as attributes. Is there anyone using XSL stylesheet to transform the 
> original xml to desired xml result? Thanks in advanced.
> 
> Original Xml File Structure:
> <?xml version="1.0" standalone="yes"?>
> <NewDataSet>
>   <Products>
>     <ProductID>01</ProductID>
>     <ProductName>Raffles Chips</ProductName>
>     <UnitPrice>8.2500</UnitPrice>
>     <Quantity>1000</Quantity>
>     <ReorderLevel>50</ReorderLevel>
>   </Products>
>   <Products>
>     <ProductID>02</ProductID>
>     <ProductName>GG Corn Chips</ProductName>
>     <UnitPrice>7.5000</UnitPrice>
>     <Quantity>1000</Quantity>
>     <ReorderLevel>50</ReorderLevel>
>   </Products>
>   <Products>
>     <ProductID>03</ProductID>
>     <ProductName>J&J V-Cut Chips</ProductName>
>     <UnitPrice>7.5000</UnitPrice>
>     <Quantity>2000</Quantity>
>     <ReorderLevel>100</ReorderLevel>
>   </Products>
>   <Products>
>     <ProductID>04</ProductID>
>     <ProductName>te</ProductName>
>     <UnitPrice>5.2500</UnitPrice>
>     <Quantity>56</Quantity>
>     <ReorderLevel>4</ReorderLevel>
>   </Products>
>   <Products>
>     <ProductID>05</ProductID>
>     <ProductName>Jack</ProductName>
>     <UnitPrice>4.5000</UnitPrice>
>     <Quantity>200</Quantity>
>     <ReorderLevel>1</ReorderLevel>
>   </Products>
>   <Products>
>     <ProductID>06</ProductID>
>     <ProductName>GHH</ProductName>
>     <UnitPrice>8.0000</UnitPrice>
>     <Quantity>920</Quantity>
>     <ReorderLevel>7</ReorderLevel>
>   </Products>
> </NewDataSet>
> 
> Desired Xml Transformation(Result):
> <?xml version="1.0" encoding="utf-8"?>
> <Products>
> 	<Product Name="Raffles Chips" ID="01">		
> 		<UnitPrice>8.2500</UnitPrice>
> 		<Quantity>1000</Quantity>
> 		<ReorderLevel>50</ReorderLevel>
> 	</Product>
> 	<Product Name="GG Corn Chips" ID="02">		
> 		<UnitPrice>7.5000</UnitPrice>
> 		<Quantity>1000</Quantity>
> 		<ReorderLevel>50</ReorderLevel>
> 	</Product>
> 	<Product Name="J&J V-Cut Chips" ID="03">		
> 		<UnitPrice>7.5000</UnitPrice>
> 		<Quantity>2000</Quantity>
> 		<ReorderLevel>100</ReorderLevel>
> 	</Product>
> 	<Product Name="te" ID="04">		
> 		<UnitPrice>5.2500</UnitPrice>
> 		<Quantity>56</Quantity>
> 		<ReorderLevel>4</ReorderLevel>
> 	</Product>
> 	<Product Name="Jack" ID="05">		
> 		<UnitPrice>4.5000</UnitPrice>
> 		<Quantity>200</Quantity>
> 		<ReorderLevel>1</ReorderLevel>
> 	</Product>
> 	<Product Name="GHH" ID="06">		
> 		<UnitPrice>8.0000</UnitPrice>
> 		<Quantity>920</Quantity>
> 		<ReorderLevel>7</ReorderLevel>
> 	</Product>
> </Products>
> 
> 
> den2005
> 
> -- 
> MCP Year 2005, Philippines


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent