XSLTForms/HelloWorld
外觀
如果 XSLTForms 安裝正確,則以下表單(或與此類似的表單)即可正常工作。
<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/01/xforms"
xmlns:my="http://www.example.com/my-data">
<head>
<!--The Model is defined within the head of the xhtml document-->
<xforms:model>
<!--The instance is defined within the model-->
<xforms:instance>
<my:data>Hello World</my:data>
</xforms:instance>
</xforms:model>
</head>
<body>
<!--The view is defined within the body of the document-->
<xforms:group>
<xforms:output ref="/my:data">
<xforms:label>Output Control Example</xforms:label>
</xforms:output>
</xforms:group>
</body>
</html>
備註
該表單包括一個 xml-stylesheet 處理指令(第 1 行,已突出顯示)。href 偽屬性的值應為對 xsltforms.xsl 樣式表的相對引用。該示例假定 XSLTForms 庫已安裝在子目錄 xsltforms 中;相對引用的值將根據庫的相對位置以及表單位置而有所不同。例如在另一個上下文中,處理指令可能為 <?xml-stylesheet href="../../../lib/xsltforms-1.0RC2/xsltforms.xsl" type="text/xsl"?>。