Agiungere namespace

sabato 14 settembre 2013 - 16.01

sviluppo_tris Profilo | Newbie

Buondi..ho un grosso problema ho fatto una xslt per aggiungere dei name space ad un xml.
questo è xslt che ho fatto io:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/*">
<xsl:element name="{name()}" namespace="www.m.it/v/g">
<xsl:call-template name="agg"/>
</xsl:element>
</xsl:template>
<xsl:template name="agg">
<xsl:choose>
<xsl:when test="count(child::*)>0">
<xsl:for-each select="child::*">
<xsl:element name="{name()}" namespace="www.m.it/v/g">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>
<xsl:call-template name="agg"/>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

----questo è l'input che do all'xslt:
<RSP>
<U>3482</U>
<S>ATA</S>
<T>P</T>
<S>AE</S>
<E>K</E>
<A>
<T>F</T>
<PF>
<Co>C</Co>
<C>C</C>
<N>T</N>
<D>1-02</D>
<C>R</C>
</PF>
</A>
</RSP>
---questo è quello che mi esce:
<RSP xmlns="www.m.it/v/g">
<U>3482</U>
<S>ATA</S>
<T>P</T>
<S>AE</S>
<E>K</E>
<A>
<T>F</T>
<PF>
<Co>C</Co>
<C>C</C>
<N>T</N>
<D>1-02</D>
<C>R</C>
</PF>
</A>
</RSP>
mentre questo è quello che dovrebbe venire:
<ns1:RSP xmlns:ns1="www.m.it/v/g">
<U xmlns:m="www.m.it/v/g">3</U>
<S xmlns:m="www.m.it/v/g">A</S>
<T xmlns:m="www.m.it/v/g">PP</T>
<S xmlns:m="www.m.it/v/g">AE</S>
<E xmlns:m="www.m.it/v/g">O</E>
<A xmlns:m="www.m.it/v/g">
<T>F</T>
<PF>
<Co>CV</Co>
<C>CV</C>
<N>TD</N>
<D>1962</D>
<C>R</C>
</PF>
</A>
</ns1:RSP>
in pratica non riesco a fa scrivere ns1:davanti a RISp e inserire gli altri namespace..spero di essere stato chiaro
grazie mille
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5