add a new element into an xml file with the same namespace
Posted: Tue Sep 14, 2004 7:37 pm
hi,
I have a big problem and I hope that someone could help me.
if an element isn't present into the xml file, I want insert it.
The xsl to trasform the xml is:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="">
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="c:Insinuazione" xmlns:c="http://www.giustizia.it/Concorsuali/StatoPassivo">
<xsl:copy>
<xsl:if test="count(c:NumeroInsinuazione)=0">
<xsl:element name="NumeroInsinuazione"/>
</xsl:if>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:stylesheet>
if NumeroInsinuazione is not in the xml, the xsl trasfom it adding the element.
The problem is that I want that the new element takes the same namespace suffix of the source xml, otherwise I can't validate it.
Is it possible to do it?
best regards
I have a big problem and I hope that someone could help me.
if an element isn't present into the xml file, I want insert it.
The xsl to trasform the xml is:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="">
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="c:Insinuazione" xmlns:c="http://www.giustizia.it/Concorsuali/StatoPassivo">
<xsl:copy>
<xsl:if test="count(c:NumeroInsinuazione)=0">
<xsl:element name="NumeroInsinuazione"/>
</xsl:if>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:stylesheet>
if NumeroInsinuazione is not in the xml, the xsl trasfom it adding the element.
The problem is that I want that the new element takes the same namespace suffix of the source xml, otherwise I can't validate it.
Is it possible to do it?
best regards