Das ist mein XML
XSLT
mit:XSLT - In zwei Namespaces in einem Knoten
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RequestResponse xmlns="http://tempuri.org/">
<RequestResult>
<Message>Request inserted successfully.</Message>
<Response>true</Response>
</RequestResult>
</RequestResponse>
</s:Body>
</s:Envelope>
Und ich möchte zwei Namespaces hinzufügen im RequestResult
Knoten (das Ergebnis ich will):
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RequestResponse xmlns="http://tempuri.org/">
<RequestResult xmlns:a="http://schemas.datacontract.org/2004/07/MockupTesting" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Message>Request inserted successfully.</a:Message>
<a:Response>true</a:Response>
</RequestResult>
</RequestResponse>
</s:Body>
</s:Envelope>
ich benutze dieses XSLT:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<xsl:apply-templates />
</s:Body>
</s:Envelope>
</xsl:template>
<xsl:template match="RequestResult |RequestResult //*">
<xsl:element name="a:{name()}"
namespace="http://schemas.datacontract.org/2004/07/MockupTesting">
<xsl:copy-of select="namespace::*" />
<xsl:apply-templates select="node()|@*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Aber ich muss den SolicitarPeticionResult
Knoten (die bereits enthält einen Namespace) hinzuzufügen:
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
Es gibt es viele Antworten auf SO über das Hinzufügen von Namespaces zu XML mit XSLT - versuchen Sie es. –
Ich bearbeitet, nur eine Antwort, wie zwei Namespaces zu einem Knoten hinzufügen. – gtx911