xsl:element problem

Having trouble installing Oxygen? Got a bug to report? Post it all here.
meciccio
Posts: 6
Joined: Wed Aug 11, 2004 6:00 pm

xsl:element problem

Post by meciccio »

I have got the xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by MA (GE) -->
<!--Sample XML file generated by XMLSPY v2004 rel. 3 U (http://www.xmlspy.com)-->
<n:DepositoInsinuazioni xmlns:n="http://www.giustizia.it/Concorsuali/StatoPassivo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.giustizia.it/Concorsuali/StatoPassivo
D:\MINISTERO\Krakatoa\src\interop\xml\Insinuazioni\InsinuaETipi.xsd">

...


<n:Insinuazione>
<n:Identificativo n:CodiceFiscale="VRDMRA59A25E379B"/>
<n:Credito>
<n:NumeroCredito>1</n:NumeroCredito>
<n:Importo>556.00</n:Importo>
<n:Privilegio>010</n:Privilegio>
<n:Sorte>556.00</n:Sorte>
<n:DataDecorrenza>1998-12-01</n:DataDecorrenza>
<n:Descrizione>String</n:Descrizione>
</n:Credito>
</n:Insinuazione>
</n:DepositoInsinuazioni>

I'm trying to insert a new element <Numero> after the tag </n:Insinuazione>

I'm using xsl to insert this new tag, but nothig change after I have done the XSL transformation.

the xsl file is :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="DepositoInsinuazioni/Insinuazione">
<xsl:element name="Numero">
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

someone can say me what's going wrong?

thanks
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

The following stylesheet will do it

Code: Select all


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="n:Insinuazione" xmlns:n="http://www.giustizia.it/Concorsuali/StatoPassivo">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
<xsl:element name="Numero"/>
</xsl:template>

</xsl:stylesheet>
Best Regards,
George
meciccio
Posts: 6
Joined: Wed Aug 11, 2004 6:00 pm

Post by meciccio »

thanks george,
your stylesheet works perfectly.
Post Reply