QT使用xsl将xml为html,使用xslt 2.0将属性设置为根元素(Puting attributes to the root-element with xslt 2.0)...

使用xslt 2.0将属性设置为根元素(Puting attributes to the root-element with xslt 2.0)

是否可以使用xslt 2.0将xml:lang或lang属性放入html根元素 ?

问题是, xsl:stylesheet唯一允许的属性是: id , exclude-result-prefixes , extension-element-prefixes , version ,当然还有xmlns 。 任何xslt-processor都会忽略其他属性。

必须有一种方法来扩展元素我希望?

非常感谢。

代码(在这种情况下为xhtml):

xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"

xmlns:fn="http://www.w3.org/2005/xpath-functions"

xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:tst="http://www.ma-buwi-fh.de"

xmlns="http://www.w3.org/1999/xhtml"

xml:lang="de">

encoding="UTF-8"

indent="yes"

doctype-public='-//W3C//DTD XHTML 1.1//EN'

doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'

/>

结果如下:

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

PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

xmlns:fn="http://www.w3.org/2005/xpath-functions"

xmlns:tst="http://www.ma-buwi-fh.de"

xmlns="http://www.w3.org/1999/xhtml">

Is it possible to put a xml:lang or lang attribute to the html root-element using xslt 2.0?

The problem is, that the only allowed attributes for xsl:stylesheet are: id, exclude-result-prefixes, extension-element-prefixes, version and of course xmlns. Other attributes are being ignored by any xslt-processor.

There must be a way to extend the element I hope?

Thanks a lot.

Code (xhtml in this case):

xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"

xmlns:fn="http://www.w3.org/2005/xpath-functions"

xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:tst="http://www.ma-buwi-fh.de"

xmlns="http://www.w3.org/1999/xhtml"

xml:lang="de">

encoding="UTF-8"

indent="yes"

doctype-public='-//W3C//DTD XHTML 1.1//EN'

doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'

/>

The result looks like this:

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

PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

xmlns:fn="http://www.w3.org/2005/xpath-functions"

xmlns:tst="http://www.ma-buwi-fh.de"

xmlns="http://www.w3.org/1999/xhtml">

原文:https://stackoverflow.com/questions/21484455

更新时间:2019-06-12 10:32

最满意答案

您错误地将stylesheet元素(XSLT样式表的根元素) html (HTML文档的根元素)。

您引用的属性是stylesheet元素允许的属性。 请参阅此处的规范的相关部分。

因此,在输出的html元素上指定lang属性,而不是在stylesheet元素上指定。

如果您希望任何人诊断您的实际问题,您必须显示您的XSLT代码。

You are mistaking the stylesheet element (the root element of an XSLT stylesheet) for html (the root element of an HTML document).

The attributes you cite are the ones allowed for the stylesheet element. See the relevant part of the specification here.

So, specify the lang attribute on the html element you output, not on the stylesheet element.

If you want anyone to diagnose your actual problem, you must needs show your XSLT code.

相关问答

您错误地将stylesheet元素(XSLT样式表的根元素) html (HTML文档的根元素)。 您引用的属性是stylesheet元素允许的属性。 请参阅此处的规范的相关部分。 因此,在输出的html元素上指定lang属性,而不是在stylesheet元素上指定。

...

我会将元素推送到身份转换,请参阅http://xsltransform.net/bdxtqy <?xml version="1.0" encoding="UTF-8" ?>

...

您正在寻找的模式是“修改的身份转换”。 这种方法的基础是身份转换规则,这是下面样式表中的第一个模板规则。 之后的每条规则都表示复制行为的例外。

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

...

QtWebKit和xslt总是分开的,将它们组合起来总是一个待办事项 - 不确定当前状态是什么,但你可以用示例轻松测试它。 或者按照http://labs.trolltech.com/blogs/2010/03/03/qtwebkit-releases/ QtWebKit and xslt were always seprate, combining them was always a todo - not sure what the current status is but you can e

...

即使在xslt模板中没有有效的属性分隔符,它也适用于MS Visual Studio 2013。 尝试这个 <?xml version="1.0" encoding="UTF-8"?>

...

没有一个浏览器本身支持XSLT 2.0。 但是,您可以通过Saxon-CE库在浏览器中使用XSLT 2.0。 请参阅http://www.saxonica.com/ce/user-doc/1.1/index.html上的文档(它本身使用Saxon-CE进行渲染)。 None of the browsers support XSLT 2.0 natively. However, you can use XSLT 2.0 in the browser via the Saxon-CE library.

...

这应该完成你所描述的:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

exclude-result-prefixes="xsi">

...

除了将version属性更改为'2.0' ,还需要将XSLT 2.0代码提供给XSLT 2.0处理器 。 目前,我使用的一些XSLT 2.0处理器是: Saxon 9.x XQSharp 2.0 AltovaXML (XMLSpy) 请注意 ,现有的XSLT 1.0代码在XSLT 2.0下可能会有不同的行为 - 最明显的区别是不再生成来自节点集的第一个节点的字符串值,以及XSLT中的字符串值2.0已经消除了可怕的RTF类型,因此不需要/提供xxx:node-set()扩

...

在我看来,XSLT 2.0已经很好了: 推荐w3c 但我真的不确定,它是否已经得到支持。 编辑: 维基百科说: XSLT由万维网联盟(W3C)开发。 最新版本是XSLT 2.0 [4],它于2007年1月23日达到W3C推荐状态。然而,截至2010年,XSLT 1.0 [5]仍然被广泛使用,因为没有产品支持在浏览器中运行XSLT 2.0 ,也不是某些重要的服务器环境,如LAMP。 XSLT 2.0 is already finished: W3C recommendation But it see

...

libxslt实现了XSLT 1.0。 这是它的初始范围: Libxslt-0.1.0是第一个测试版,它应该涵盖XSLT-1.0规范中的大多数功能,但它显然尚未完成。 检查FEATURES文件以获得准确的想法。 这是目前的范围: Libxslt是为GNOME项目开发的XSLT C库。 XSLT本身是一种XML语言,用于定义XML的转换。 Libxslt基于libxml2,它是为GNOME项目开发的XML C库。 它还实现了大多数EXSLT处理器可移植扩展函数集以及Saxon的一些评估和表达式扩展。

...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值