Mike Deuter: xml in eine ander xml konvertieren

Beitrag lesen

Hallo,

ich wollte mal anfragen, ob jemand von euch mir einen tipp geben koennte. Und zwar muss ich ein xml dokument in ein anderes dokumnet umwandeln. dabei handelt es sich grob gesagt um dokumnete, die einen vergleichbaren aufbau wie xhtml usw. haben. das ganze läuft auch ganz gut, wenn es da nicht solche trick fälle geben würde. Im allgemein gehe ich so vor, dass ich stufenweise das dokument abarbeite mit xsl:apply-templates. Z.B:

<xsl:apply-template select="body"/>

<xsl:template match="body">
<body>
<xsl:apply-templtes select="nparag"/>
</body>
</xsl:template>

<xsl:template match="nparag">
...
</xsl:template>

ich muss nun nicht in xhtml umwandeln, aber in ein ähnliches format. Anbei ein beispiel, an dem ich langsam verzweifle. der obere teil stellt die xml quelle dar und der untere teil, wo ich hinkommen möchte. Allein mit apply-template scheine ich da nicht weiter zu kommen.

<nparag>this is a <ref> element</ref> text: <seqlist>
            <item>
                <para>listes parag. text</para>
            </item>
            <item>
                <para>listes parag. text</para>
            </item>
            <item>
                <para>listes parag. text</para>
            </item>
            <item>
                <para>listes parag. text<standard>another inbound element</standard>and the text goes on.</para>
            </item>
        </seqlist>
        <para>another text</para>
    </nparag>
    <!-- should be converted to -->
    text:pthis is a <refnew> element</refnew> text: </text:p>
    text:list
        text:list-item
            text:plistes parag. text</text:p>
        </text:list-item>
        text:list-item
            text:plistes parag. text</text:p>
        </text:list-item>
        text:list-item
            text:plistes parag. text</text:p>
        </text:list-item>
        text:list-item
            text:plistes parag. text<otherstandard>another inbound element</otherstandard>and the text goes on.</text:p>
        </text:list-item>
    </text:list>
    text:panother text</text:p>