国米preting换行符用xsl:文本? [英] Interpreting newlines with xsl:text?

查看:211
本文介绍了国米preting换行符用xsl:文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在 XSL内容的XSL样式表:像这样的文字节点:

 < XSL:文本>

酒吧
巴兹
< / XSL:文本>

样式表本身就是UNIX风格换行符行终止符的文本文件。我祈求在Windows上的样式表,以及类UNIX平台。这将是不错的输出符合在调用它的平台的约定。

当我在Windows上运行这个样式表,输出具有一切的除了的的的内容XSL回车/换行符对:文本节点

我可以指示XSLT处理器在 XSL的内容换行字符翻译:文本节点到平台特定的尾线

更多的上下文:我援引从 Apache Ant的1.7.1 XSLT任务喜欢的样式表这样的:

 < XSLT中=in.xml中出=out.xml的风格=stylesheet.xsl/>

样式表头目前看起来是这样的:

 <?XML版本=1.0&GT?;
<的xsl:样式版本=1.0
    的xmlns:XSL =htt​​p://www.w3.org/1999/XSL/Transform
    的xmlns:xalan的=htt​​p://xml.apache.org/xslt
    排除-result- prefixes =xalan的>
    <! - 省略的内容 - >
< / XSL:样式>


解决方案

您可以定义一个参数,像这样的样式表:

 < XSL:PARAM NAME =BR>
< XSL:文本>&放大器;#10;< / XSL:文本>
< / XSL:参数>

和行字符(S)的适当端在Ant脚本使用嵌套param元素通过。在本实施例的默认将是Unix风格换行符,当然。我认为要输出的值,你必须使用:

 < XSL:复制的选择=$ BR/>

这是冗长的,但它的作品。

I have an XSL stylesheet with content in an xsl:text node like this:

<xsl:text>
foo
bar
baz
</xsl:text>

The stylesheet itself is a text file with "unix-style" newline line terminators. I invoke this stylesheet on Windows as well as unix-like platforms. It would be nice to have the output conform to the conventions of the platform on which it is invoked.

When I run this stylesheet on Windows, the output has carriage return/newline pairs for everything except the contents of the xsl:text node.

Can I instruct the XSLT processor to translate the newline characters in the content of the xsl:text node into platform specific end-of-lines?

More context: I'm invoking the stylesheet from the Apache Ant 1.7.1 XSLT task like this:

<xslt in="in.xml" out="out.xml" style="stylesheet.xsl"/>

The stylesheet header currently looks like this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xalan="http://xml.apache.org/xslt"
    exclude-result-prefixes="xalan">
    <!-- contents elided -->
</xsl:stylesheet>

解决方案

You could define a parameter for the stylesheet like so:

<xsl:param name="br">
	<xsl:text>&#10;</xsl:text>
</xsl:param>

and pass in the appropriate end of line character(s) by using a nested param element in your Ant script. The default in this example would be a Unix-style newline, of course. I think to output the value, you'd have to use:

<xsl:copy-of select="$br"/>

It's verbose, but it works.

这篇关于国米preting换行符用xsl:文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆