Re: AW: AW: [xsl] Detecting carriage return and newline feed in XML Data

Subject: Re: AW: AW: [xsl] Detecting carriage return and newline feed in XML Data
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 1 Nov 2004 13:43:49 +0000
Hi Lawrence,

> 4. The System Architect cleverly export all structured diagrams and
> their properties into one single XML. The text field described
> before is as well stored as an attribut of an XML element.

As others have pointed out, you can't see the CR/LF characters in the
attribute using XSLT, since they're normalised away during XML
parsing. The best thing to do is go to Popkin Software, complain that
the XML that System Architect is generating isn't structured at all
helpfully, and insist that they change it.

In the meantime, though, perhaps you can use the fact that the
paragraphs end in a full stop (period to our American friends) and
indented using two-or-more spaces to access them. Try something like:

<xsl:template match="SAProperty[@SAPrpName = 'Description']">
  <xsl:param name="desc" select="@SAPrpValue" />
  <xsl:choose>
    <xsl:when test="contains($desc, '.  ')">
      <para>
        <xsl:value-of
          select="normalize-space(substring-before($desc, '.  '))" />
        <xsl:text>.</xsl:text>
      </para>
      <xsl:apply-templates select=".">
        <xsl:with-param name="desc"
                        select="substring-after($desc, '.  ')" />
      </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
      <para>
        <xsl:value-of select="normalize-space($desc)" />
      </para>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread