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的一些評估和表達式擴展。
...
總結
以上是生活随笔為你收集整理的QT使用xsl将xml为html,使用xslt 2.0将属性设置为根元素(Puting attributes to the root-element with xslt 2.0)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 半瓶神仙醋游戏新作,《大侠立志传:碧血丹
- 下一篇: 天津消协点名:奔驰4s店未提供真实全面定