Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Transform Xml w/ attributes... >Thread Next - Re: [RESOLVED] RE: Transform Xml w/ attributes... [RESOLVED] RE: Transform Xml w/ attributes...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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
