XSLT Search trough XML / Write Text without one specific element

Here should go questions about transforming XML with XSLT and FOP.
realbadfox
Posts: 1
Joined: Wed May 09, 2018 2:08 pm

XSLT Search trough XML / Write Text without one specific element

Post by realbadfox »

Hallo Guys,

I have this code for searchgin through a XML and write it in an text file.

Every Element with every attribute and so on.

This is working perfect, but i want to write the same without one specific Element name, and without the child elements of it. So for example without the "STPDatenKFS" element end its childs.

XML:

Code: Select all

<DokumentenListe>
<Dokument>
<Typ TypID="Plan">Plan</Typ>
<Dateiname>xxx.pdf</Dateiname>
</Validierungsergebnis>
<STPPruefergebnis>fehlerfrei</STPPruefergebnis>
<kaMeStpVersion>1.2.4</kaMeStpVersion>
</Dokument>
<Dokument>
<Typ TypID="STPVaReport">STPVaReport</Typ>
<Dateiname>yyy.pdf</Dateiname>
<MimeType>application/pdf</MimeType>
<Link>yyy.pdf</Link>
</Dokument>
</DokumentenListe>
<STPDatenKFS>
<Metadaten Fehler="fehlerfrei">
<kaMeKgNr>12345</kaMeKgNr>
</Metadaten>
</TSTDaten>
</STPDatenKFS>
XSLT:

Code: Select all

<xsl:for-each select="/descendant-or-self::node()">
<xsl:choose>
<xsl:when test="self::*">
<xsl:for-each select="ancestor::*">
<xsl:text>AA</xsl:text>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>BB</xsl:otherwise>
</xsl:choose>
<xsl:if test="self::*">
<span class="pre-elem">
<xsl:value-of select="local-name(.)"/>
</span>
<xsl:text>CC</xsl:text>
<xsl:for-each select="@*">
<span class="pre-attr">
<xsl:value-of select="local-name(.)"/>=<xsl:value-of select="."/>
</span>
<xsl:text>DD</xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:if>
<xsl:if test="self::text()">
<span class="pre-text">
<xsl:value-of select="."/>
</span>
</xsl:if>
<xsl:if test="not(child::text())">
<xsl:text>&#10; EE</xsl:text>
</xsl:if>
</xsl:for-each>
OUTPUT:

Code: Select all

DokumentenListe
Dokument
Typ TypID=Plan Plan
Dateiname xxx.pdf
Validierungsergebnis
STPPruefergebnis fehlerfrei
kaMeStpVersion 1.2.4
Dokument
Typ TypID=STPVaReport STPVaReport
Dateiname yyy.pdf
MimeType application/pdf
Link yyy.pdf
STPDatenKFS
Metadaten Fehler=fehlerfrei
kaMeKgNr 12345
TSTDaten
please help me.

thanks yours chris