Ich muss ein Sub-XML von einigen XML-Datei erstellen. Ich habe eine Liste der erforderlichen Knoten. Wie sollte xslt Transformation aussehen? Zum Beispiel Eingabedatei:xslt Transformation von xml zu xml spezifischen Knoten kopieren omly
<?xml version="1.0"?>
<root>
<a id="A">
<aa>text</aa>
<bb>text</bb>
<cc id="1">
<aaa>text</aaa>
<bbb>text</bbb>
</cc>
</a>
<a id="B">
<aa>text2</aa>
<bb>text2</bb>
<cc id="2">
<aaa>text2</aaa>
<bbb>text2</bbb>
</cc>
</a>
</root>
gewünschte Ausgabe:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<a id="A">
<bb>text</bb>
<cc>
<bbb>text</bbb>
</cc>
</a>
<a id="B">
<bb>text2</bb>
<cc>
<bbb>text2</bbb>
</cc>
</a>
</root>
Derzeit verwende ich follwonf Xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output indent="yes"/>
<xsl:template match="node()|@*"/>
<xsl:template match="
root
|root/a
|root/a/@id
|root/a/bb
|root/a/bb/node()
|root/a/cc
|root/a/cc/bbb
|root/a/cc/bbb/node()
">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Aber ich möchte kürzer etwas wie diese Liste haben:
root/a/@id
|root/a/bb/node()
|root/a/cc/bbb/node()
Also, wie xslt Transformation für diese kurze Liste zu erstellen?
Danke! Genau das, was ich brauche. Ich weiß nicht, wie diese Magie funktioniert, aber es funktioniert und es ist eine Hauptsache für mich jetzt! – qwerty1222