Jump to content

XSLTForms/HelloWorld

From Wikibooks, open books for an open world

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

  <?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>

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"?>.