0

I'm generating a plaintext file from an XML document. In the template, I have a simplified version of HTML that uses <p>, <ul>, <li>, <pre> and a few others.

In the source document, I have a node that looks like this:

<p>The respond category obeys the category laws, where respond is the identity and (/&gt;/) is composition:</p>

Near the bottom of my template, I have the following relevant rules:

<xsl:template match="p">
  <xsl:text>  </xsl:text>
  <xsl:apply-templates select="* | text()"/>
  <xsl:text>&#10;</xsl:text>
</xsl:template>
<xsl:template match="text()">
  <xsl:value-of disable-output-escaping="yes" select="."/>
</xsl:template>

This works fine. I get the following output:

The respond category obeys the category laws, where respond is the identity and (/>/) is composition:

Now, here's where things go wrong. Based on an answer to another SO question, I discovered that I can get the output to line wrap with this change to the rule for <p> tags:

<xsl:template match="p">
  <xsl:variable name="aaa">
    <xsl:apply-templates select="* | text()"/>
  </xsl:variable>
  <xsl:sequence select="replace(concat(normalize-space($aaa),' '), '(.{0,60}) ', '  $1&#10;')"/>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

This give me the following output:

The respond category obeys the category laws, where respond
is the identity and (/&gt;/) is composition:

It correctly wraps and left pads the output. However, the > symbol is now escaped. I tried adding disable-output-escaping="yes" to sequence, but saxonb errors with:

XTSE0090: Attribute @disable-output-escaping is not allowed on element <xsl:sequence>

Is there a way to avoid escaping the > symbol is this situation?

Community
  • 1
  • 1

1 Answers1

0

I needed to add xsl:output method="text", as mentioned by Martin in the comments.