Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Help with transform needed [Thread Next] Re: Help with transform neededTo: NULL Date: 4/9/2008 10:06:00 AM
"chris fellows" <chrisfellows@n...> wrote in message
news:e5lt%23MamIHA.4208@T......
>I need some help to transform some input XML. In the input XML the FromDate
>and ToDate elements are identical within every Row element but, on the
>output XML, I want them to appear as attributes of the root node. Can
>someone help me out with the XSL?
>
> Input XML:
>
> <InputDataSet>
> <Row>
> <FromDate>21-03-2008 18:00</FromDate>
> <ToDate>22-03-2008 23:59</ToDate>
> <Data>12345</Data>
> </Row>
> <Row>
> <FromDate>21-03-2008 18:00</FromDate>
> <ToDate>22-03-2008 23:59</ToDate>
> <Data>6789</Data>
> </Row>
> </InputDataSet>
>
>
> Output XML:
>
> <OutputDataSet FromDate="21-03-2008 18:00" ToDate="22-03-2008 23:59">
> <Row>
> <SomeData>12345</SomeData>
> </Row>
> <Row>
> <SomeData>6879</SomeData>
> </Row>
> </OutputDataSet>
>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<OutputDataSet FromDate="{(*/Row/FromDate)[1]}"
ToDate="{(*/Row/ToDate)[1]}">
<xsl:apply-templates select="*/Row"/>
</OutputDataSet>
</xsl:template>
<xsl:template match="Row">
<Row><xsl:value-of select="Data"/></Row>
</xsl:template>
</xsl:stylesheet>
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
