Announcement

Collapse
No announcement yet.

XSL Leerzeichen werden nicht ausgegeben

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • XSL Leerzeichen werden nicht ausgegeben

    Hallo,
    ich habe das Problem, dass die Leerzeichen aus meiner Datei im Zieldokument nicht mit ausgegeben werden. Ich vermute, dass es am XSLT-Prozessor liegt, weil Saxon es richtig ausgibt. Ich muss es aber mit AltovaXML2013 ausgeben.
    Hat jemand Erfahrung damit? Wie kann ich die Leerzeichen erhalten. Mit xml:space und preserve-space habe ich es auch schon versucht

    Quelle:
    Code:
    <book>
        <p><em>Das</em> <b>ist</b> <em>ein</em> Text</p>
    </book>
    XSL:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="2.0">
        <xsl:output method="text" encoding="UTF-8"/>
           
        <xsl:template match="/">
            <xsl:apply-templates/>
        </xsl:template>
        
        <xsl:template match="p">
            <p><xsl:apply-templates/></p>
        </xsl:template>
        
        <xsl:template match="em">
            <xsl:text>_</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>_</xsl:text>
        </xsl:template>
        
    </xsl:stylesheet>
    Ergebnis:
    Code:
    _Das_ist_ein_ Text

  • #2
    Das ist ein dokumentierter Quirk oder sogar Bug, siehe http://manual.altova.com/AltovaXML/a...nformation.htm, wo steht:
    Whitespace in XML document

    By default, the Altova XSLT 2.0 Engine strips all boundary whitespace from boundary-whitespace-only nodes in the source XML document. The removal of this whitespace affects the values that the fnosition(), fn:last(), fn:count(), and fn:deep-equal() functions return. For more details, see Whitespace-only Nodes in XML Document in the XPath 2.0 and XQuery 1.0 Functions section.



    Note: If a boundary-whitespace-only text node is required in the output, then insert the required whitespace within one of the two adjoining child elements. For example, the XML fragment:



    <para>This is <b>bold</b> <i>italic</>.</para>



    when processed with the XSLT template



    <xsl:template match="para">

    <xsl:apply-templates/>

    </xsl:template>



    will produce:



    This is bolditalic.



    To get a space between bold and italic in the output, insert a space character within either the <b> or <i> elements in the XML source. For example:



    <para>This is <b>bold</b> <i> italic</>.</para> or

    <para>This is <b>bold </b> <i>italic</>.</para> or

    <para>This is <b>bold</b><i> italic</>.</para>



    When such an XML fragment is processed with the same XSLT template given above, it will produce:



    This is bold italic.

    Comment

    Working...
    X