简体   繁体   中英

xsltproc: Can I add breaks (or entities) to --stringparams?

I am trying to feed xsltproc a stringparam that contains a break... It does not seem to work. Minimal example below.

Input

This is bogus.xml :

<?xml version="1.0" encoding="UTF-8"?>
<this>
  <that/>
</this>

This is test.xsl :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="somestring" select="'here is a&#10;break'"/>
  <xsl:template match="/">
    <xsl:message>|<xsl:value-of select="$somestring"/>|</xsl:message>
  </xsl:template>
</xsl:stylesheet>

And this is my command line: xsltproc --stringparam somestring 'another string with a&#10;break' test.xsl bogus.xml

Output

And the output looks like this:

|another string with a&#10;break|

The output I want is this:

|another string with a
break|

When using Bash this can be achieved like this:

xsltproc --stringparam somestring $'another string with a\nbreak' test.xsl bogus.xml

For more information about ansi-c quoting see here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM