I have a xml document like this one
<?xml version="1.0" encoding="UTF-8"?>
<Message>
<Header>
<BrokerID>MAR01</BrokerID>
<TMStamp>2005-10-04T08:50:
43</TMStam
p>
</Header>
<ReportDetails>
<ReportCode>01</ReportCode
>
<ReportFromDate> </ReportFromDate>
<ReportToDate> </ReportToDate>
</ReportDetails>
<ReportData>
<Definition>
<Column ID="1" Name="Client Name" DataType="CHAR" Total="N"/>
<Column ID="2" Name="Client Reference" DataType="CHAR" Total="N"/>
<Column ID="3" Name="Policy Number" DataType="CHAR" Total="N"/>
<Column ID="4" Name="Insurer" DataType="CHAR" Total="N"/>
<Column ID="5" Name="Net Premium" DataType="NUMBER" Total="N"/>
<Column ID="6" Name="Brokerage" DataType="NUMBER" Total="N"/>
<Column ID="7" Name="Inception Date" DataType="DATE" Total="N"/>
</Definition>
<Data>
<Row>
<Cell ID="1" Value="Value1"/>
<Cell ID="2" Value="Value2"/>
<Cell ID="3" Value="Value3"/>
<Cell ID="4" Value="Value4"/>
<Cell ID="5" Value="Value5"/>
<Cell ID="6" Value="Value6"/>
<Cell ID="7" Value="Value7"/>
</Row>
</Data>
<Row>
<Cell ID="1" Value="Value11"/>
<Cell ID="2" Value="Value12"/>
<Cell ID="3" Value="Value13"/>
<Cell ID="4" Value="Value14"/>
<Cell ID="5" Value="Value15"/>
<Cell ID="6" Value="Value16"/>
<Cell ID="7" Value="Value17"/>
</Row>
</ReportData>
<ReportSummary>
<NoColumns> 0</NoColumns>
<NoRows> 0</NoRows>
</ReportSummary>
<Status>
<Reason>Request successful</Reason>
<Code>1</Code>
</Status>
</Message>
I'm applying the following stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Message xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocat
ion="Actur
isReportRe
ply.xsd">
<xsl:apply-templates select="Message"/>
</Message>
</xsl:template>
<xsl:template match="Message">
<xsl:apply-templates select="Header"/>
<xsl:apply-templates select="ReportDetails"/>
<xsl:apply-templates select="ReportSummary"/>
<xsl:apply-templates select="ReportData"/>
<xsl:apply-templates select="Status"/>
</xsl:template>
<xsl:template match="Header">
<xsl:element name="{name()}">
<xsl:attribute name="Transaction"><xsl:te
xt>AcceptR
eportReply
</xsl:text
></xsl:att
ribute>
<xsl:attribute name="BrokerID"><xsl:value
-of select="BrokerID"/></xsl:a
ttribute>
<xsl:attribute name="TMStamp"><xsl:value-
of select="TMStamp"/></xsl:at
tribute>
</xsl:element>
</xsl:template>
<xsl:template match="ReportDetails">
<xsl:element name="{name()}">
<xsl:attribute name="ReportCode"><xsl:val
ue-of select="ReportCode"/></xsl
:attribute
>
<xsl:attribute name="ReportFromDate"><xsl
:value-of select="ReportFromDate"/><
/xsl:attri
bute>
<xsl:attribute name="ReportToDate"><xsl:v
alue-of select="ReportToDate"/></x
sl:attribu
te>
</xsl:element>
</xsl:template>
<xsl:template match="ReportSummary">
<xsl:element name="{name()}">
<xsl:attribute name="NoColumns"><xsl:valu
e-of select="NoColumns"/></xsl:
attribute>
<xsl:attribute name="NoRows"><xsl:value-o
f select="NoRows"/></xsl:att
ribute>
</xsl:element>
</xsl:template>
<xsl:template match="ReportData">
<xsl:element name="{name()}">
<xsl:apply-templates select="Definition"/>
<xsl:apply-templates select="Data"/>
</xsl:element>
</xsl:template>
<xsl:template match="Status">
<xsl:element name="{name()}">
<xsl:attribute name="Reason"><xsl:value-o
f select="Reason"/></xsl:att
ribute>
<xsl:attribute name="Code"><xsl:value-of select="Code"/></xsl:attri
bute>
</xsl:element>
</xsl:template>
<xsl:template match="Definition">
<xsl:element name="{name()}">
<xsl:for-each select="Column">
<xsl:apply-templates select="Column"/>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="Data">
<xsl:element name="{name()}">
</xsl:element>
</xsl:template>
<xsl:template match="Column">
<xsl:element name="{name()}">
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I would like the following result :
<?xml version="1.0" encoding="UTF-16"?>
<Message xsi:noNamespaceSchemaLocat
ion="Actur
isReportRe
ply.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<Header Transaction="AcceptReportR
eply" BrokerID="MAR01" TMStamp="2005-10-04T08:50:
43" />
<ReportDetails ReportCode="01" ReportFromDate=" " ReportToDate=" " />
<ReportSummary NoColumns=" 0" NoRows=" 0" />
<ReportData>
<Definition>
<Column ID="1" Name="Client Name" DataType="CHAR" Total="N" />
<Column ID="2" Name="Client Reference" DataType="CHAR" Total="N" />
<Column ID="3" Name="Policy Number" DataType="CHAR" Total="N" />
<Column ID="4" Name="Insurer" DataType="CHAR" Total="N" />
<Column ID="5" Name="Net Premium" DataType="NUMBER" Total="N" />
<Column ID="6" Name="Brokerage" DataType="NUMBER" Total="N" />
<Column ID="7" Name="Inception Date" DataType="DATE" Total="N" />
</Definition>
<Data>
<Row>
<Cell ID="1" Value="Value1" />
<Cell ID="2" Value="Value2" />
<Cell ID="3" Value="Value3" />
<Cell ID="4" Value="Value4" />
<Cell ID="5" Value="Value5" />
<Cell ID="6" Value="Value6" />
<Cell ID="7" Value="Value7" />
</Row>
<Row>
<Cell ID="1" Value="Value11" />
<Cell ID="2" Value="Value12" />
<Cell ID="3" Value="Value13" />
<Cell ID="4" Value="Value14" />
<Cell ID="5" Value="Value15" />
<Cell ID="6" Value="Value16" />
<Cell ID="7" Value="Value17" />
</Row>
</Data>
</ReportData>
<Status Reason="Request successful" Code="1" />
</Message>
But instead I get the following :
<?xml version="1.0" encoding="UTF-16"?>
<Message xsi:noNamespaceSchemaLocat
ion="Actur
isReportRe
ply.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<Header Transaction="AcceptReportR
eply" BrokerID="MAR01" TMStamp="2005-10-04T08:50:
43" />
<ReportDetails ReportCode="01" ReportFromDate=" " ReportToDate=" " />
<ReportSummary NoColumns=" 0" NoRows=" 0" />
<ReportData>
<Definition />
<Data />
</ReportData>
<Status Reason="Request successful" Code="1" />
</Message>
Can somebody help me to get the result I need!!!
Start Free Trial