XSLTForms/HelloWorld

From Wikibooks, open books for an open world
Jump to: navigation, search

If XSLTForms is installed correctly, the following form (or something very similar to it) should work.

 1   <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
 2   <html xmlns="http://www.w3.org/1999/xhtml"
 3         xmlns:xforms="http://www.w3.org/2002/01/xforms" 
 4         xmlns:my="http://www.example.com/my-data">
 5        <head> 
 6               <!--The Model is defined within the head of the xhtml document-->
 7               <xforms:model> 
 8                      <!--The instance is defined within the model-->
 9                      <xforms:instance>
10                             <my:data>Hello World</my:data>
11                      </xforms:instance>
12               </xforms:model>
13        </head>
14        <body> 
15           <!--The view is defined within the body of the document-->
16           <xforms:group>
17               <xforms:output ref="/my:data">
18                   <xforms:label>Output Control Example</xforms:label>
19               </xforms:output>
20           </xforms:group>
21        </body>
22    </html>

Notes:

The form includes an xml-stylesheet processing instruction (line 1, highlighted). The value of the href pseudo-attribute should be a relative reference to the xsltforms.xsl stylesheet. The example assumes that the XSLTForms library is installed in the subdirectory xsltforms; the value of the relative reference will need to vary depending on the relative location of the library, vis-a-vis the location of the form. In another context, for example, the processing instruction might read <?xml-stylesheet href="../../../lib/xsltforms-1.0RC2/xsltforms.xsl" type="text/xsl"?>.