Ich schreibe eine XSLT entfernen, wo unten in meinem XML istich erwartete Ausgabe erhalten nur, wenn ich die streifenRäume
<?xml version="1.0" encoding="UTF-8"?>
<body>
<para>
<page num="794"/>20 July 2009
</para>
<para>
cont1<case>
<casename>
<content-style font-style="italic">cont1</content-style> & <content-style font-style="italic">Drs</content-style>
</casename>
<content-style font-style="italic">cont1</content-style>
</case> cont1 <case>
<casename>
<content-style font-style="italic">cont1</content-style> & <content-style font-style="italic">cont1</content-style> & <content-style font-style="italic">mergCont</content-style>
</casename>
<content-style font-style="italic">[2004] 3 108</content-style>
</case> regarding postponement.
</para>
<casename>
<content-style font-style="italic">Link1</content-style> & <content-style font-style="italic">Drs</content-style>
</casename>
</body>
Und unten ist mein XSLT
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:htm="http://www.w3.org/TR/html5/" exclude-result-prefixes="#all">
<xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<hmtl>
<head>
<title>New Version!</title>
</head>
<xsl:apply-templates/>
</hmtl>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template name="para" match="para">
<xsl:apply-templates select="./node()[1][self::page]" mode="first"/>
<xsl:apply-templates select="./phrase/following-sibling::node()[1][self::page]" mode="first"/>
<div>
<xsl:choose>
<xsl:when test="./@align">
<xsl:attribute name="class"><xsl:text>para align-</xsl:text><xsl:value-of select="./@align"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class"><xsl:text>para</xsl:text></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="./@num">
<xsl:variable name="phrl">
<xsl:value-of select="string-length(./@num)"/>
</xsl:variable>
<xsl:variable name="phrase">
<xsl:value-of select="concat('P',./@num)"/>
</xsl:variable>
<xsl:variable name="newphrase" select="translate($phrase,'.','-')"/>
<a>
<xsl:attribute name="name"><xsl:value-of select="$newphrase">
</xsl:value-of></xsl:attribute>
<span class="phrase">
<xsl:value-of select="./@num"/>
</span>
</a>
</xsl:if>
<xsl:choose>
<xsl:when test="./phrase/following-sibling::node()[1][self::page]">
<xsl:apply-templates select="child::node() except descendant::page[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
<!--<xsl:apply-templates/>-->
</div>
</xsl:template>
<xsl:template match="casename">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="page[not(preceding-sibling::node()[not(self::text()) or normalize-space()])]"/>
<xsl:template match="page" mode="first">
<xsl:variable name="pgn">
<xsl:value-of select="./@num"/>
</xsl:variable>
<xsl:processing-instruction name="pb">
<xsl:text>label='</xsl:text>
<xsl:value-of select="$pgn"/>
<xsl:text>'</xsl:text>
<xsl:text>?</xsl:text>
</xsl:processing-instruction>
<a name="{concat('pg_',$pgn)}"/>
</xsl:template>
<xsl:template match="page">
<xsl:variable name="pgn">
<xsl:value-of select="./@num"/>
</xsl:variable>
<xsl:processing-instruction name="pb">
<xsl:text>label='</xsl:text>
<xsl:value-of select="$pgn"/>
<xsl:text>'</xsl:text>
<xsl:text>?</xsl:text>
</xsl:processing-instruction>
<a name="{concat('pg_',$pgn)}"/>
</xsl:template>
</xsl:transform>
In meiner XSLT, Wenn ich die <xsl:strip-space elements="*"/>
entferne, bekomme ich die genaue Ausgabe. aber ich bekomme meine page
Vorlage nicht zusammen, wenn ich <xsl:strip-space elements="*"/>
hinzufüge, wird meine page
Vorlage zugeordnet, aber es fehlen Leerzeichen in meinem HTML. Unten sind die Screenshots.
mit <xsl:strip-space elements="*"/>
hier auch meine page
abgestimmt ist, aber man kann es Räume sehen vor fehlt und nach &
ohne <xsl:strip-space elements="*"/>
Hier mein page
nicht abgestimmt
Hier funktioniert DEMO. http://xsltransform.net/pPzifqu/1
Bitte lassen Sie mich wissen, wie bekomme ich Leerzeichen und auch page
Vorlage passend.
Dank
Ich würde wetten, hat zu tun mit Ihrer 'Seite [nicht (vorhergehende-Geschwister :: Knoten() [nicht (self :: text()) oder normalize-Leerzeichen()])]" /> 'Vorlage ,, Was genau willst du hier filtern? –