tags:

views:

40

answers:

1

Source XML :---I have multiple Owner with same and different value and has different contract number.

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <Table1>
    <Owner>1</Owner>
       <Contract_Number>3</Contract_Number>
    </Table1>
  <Table1>
    <Owner>1</Owner>
        <Contract_Number>4</Contract_Number>
     </Table1>
  <Table1>
    <Owner>1</Owner>
        <Contract_Number>4</Contract_Number>
     </Table1>
</NewDataSet>

OUT XML Required using XSLT :-

<?xml version="1.0" standalone="yes"?>
       <NewDataSet>
      <Table1>
        <Owner>
           <Contract_Number>3</Contract_Number>
           <Contract_Number>4</Contract_Number>
           <Contract_Number>4</Contract_Number>
        </Owner>

      </Table1>
    </NewDataSet>

I need a XSLT for above out put.Any help will be highly appreciated.

+1  A: 

It would probably help to have the actual xml file rather than a string of numbers.

Wonderful

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:output method="xml"/>
<xsl:template match="/">
<NewDataSet>
<Table1>
<Owner>
<xsl:for-each select="NewDataSet/Table1">
<Contract_Number><xsl:value-of select="Contract_Number"/></Contract_Number>
      </xsl:for-each>
</Owner>
</Table1>
</NewDataSet>
</xsl:template>
</xsl:stylesheet>
Joe Garrett
Should this have been a comment instead of an answer?
mattmc3
I have given the XML
Anand
and I have given the xsl :)
Joe Garrett
Anand, Did this work?
Joe Garrett