Thomas J.S.: xml als Text in einer xml Datei ?

Beitrag lesen

Hallo Franz, hallo Hevelmann,

» So geht's

<![CDATA[
  <xsl:copy-of select="."/>
]]>

Nein, denn so wird CDATA zum Text und er hat bloß mixed content.

Aber so geht es! ;-)
Grüße
Thomas
---------------------------

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="iso-8859-1" />

<xsl:template match="/">
xsl:apply-templates/
</xsl:template>

<xsl:template match="view">
 <document form="fmForm">
  <item name="XMLCode">
   <text>
       <![CDATA[<]]><xsl:value-of select="name()" /><xsl:for-each select="attribute::*">&#160;<xsl:value-of select="name()" />="<xsl:value-of select="." />"</xsl:for-each><![CDATA[>]]>
 <xsl:apply-templates select="child::*" />
 <![CDATA[</]]><xsl:value-of select="name()" /><![CDATA[>]]>
   </text>
  </item>
 </document>
</xsl:template>

<xsl:template match="view//*">
       <![CDATA[<]]><xsl:value-of select="name()" /><xsl:for-each select="attribute::*">&#160;<xsl:value-of select="name()" />="<xsl:value-of select="." />"</xsl:for-each><![CDATA[>]]>
 <xsl:if test="contains(., child::*)">
  xsl:apply-templates/
 </xsl:if>
 <xsl:if test="not(contains(., child::*))">
        <![CDATA[<]]><xsl:value-of select="name()" /><xsl:for-each select="attribute::*">&#160;<xsl:value-of select="name()" />="<xsl:value-of select="." />"</xsl:for-each><![CDATA[>]]>
  <xsl:value-of select="." />
  <![CDATA[</]]><xsl:value-of select="name()" /><![CDATA[>]]>
 </xsl:if>
 <![CDATA[</]]><xsl:value-of select="name()" /><![CDATA[>]]>
</xsl:template>

</xsl:stylesheet>