Forms-pi

From W3C XForms Group Wiki (Public)

W3C

Associating XML Documents with XForms using the XML-Stylesheet PI

W3C Working Group Note 1 November 2004

This version
http://www.w3.org/TR/2004/NOTE-stylesheet-pi-20041101
Latest version
http://www.w3.org/TR/stylesheet-pi
Editors
Mikko Honkala, Helsinki University of Technology
Steven Pemberton, CWI/W3C

Copyright ©2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.


Abstract

This document describes the use of the XML-Stylesheet PI to associate XML Documents with appropriate XForms [#ref-xforms [XForms]].

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document is a W3C Working Group Note, made available for discussion by the W3C XForms Working Group as part of the XForms Activity within the W3C Interaction Domain. The authors of this document are the XForms Working Group participants.

The XForms Working Group may update this document; feedback is welcome and should be sent to www-forms-editor@w3.org (archive).

Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Table of Contents

  • 1 [#stylesheet-pi xml-stylesheet]
  • [#references References]

1 xml-stylesheet

XML documents can be associated with editor documents, such as XHTML XForms documents, by using a processing instruction whose target is xml-stylesheet.

If the href attribute of this PI refers to a document containing XForms, the user agent should do the following:

  • Follow the processing defined in [#ref-xml-stylesheet [xml-stylesheet]].
  • Make the editor document referred to by the href attribute the current document.
  • Replace the ancestors of an XForms instance element in the editor document with the contents of the document containing the processing instruction:
    • If the href attribute of the PI contains a fragment identifier, that id is used to determine the instance element in the editor document. If the href attribute does not contain a fragment identifier, then the first instance element, in document order, is used.
    • If the fragment identifier refers to a non-existent id, or there is no XForms instance element in the editor document, then processing fails.

The following example would cause the document user_edit.xhtml to be loaded into the user agent, and the instance with id userinstance to be replaced with the document which contained the invoking xml-stylesheet PI:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="application/xml" title="User editor"
                 href="user_edit.xhtml#userinstance"?>
<user>
    <name>John Doe</name>
    <homepage>http://www.example.com/u/johndoe</homepage>
</user>

The user_edit.xhtml document might look like:

<h:html xmlns:h="http://www.w3.org/1999/xhtml"
        xmlns="http://www.w3.org/2002/xforms">
<h:head>
    <h:title>Edit user</h:title>
    <instance id="userinstance"/>
</h:head>
<h:body>
    <input ref="name"><label>Name</label></input>
    <input ref="homepage"><label>Homepage</label></input>
</h:body>
</h:html>

References

[xml-stylesheet]
Associating Style Sheets with XML documents Version 1.0, W3C Recommendation, James Clark, editor, 29 June 1999.
Available at: http://www.w3.org/1999/06/REC-xml-stylesheet-19990629
The latest version is available at: http://www.w3.org/TR/xml-stylesheet
[XForms]
XForms 1.0, W3C Recommendaton, M. Dubinko et al., eds., 14 October 2003.
Available at: http://www.w3.org/TR/2003/REC-xforms-20031014/
The latest version is available at: http://www.w3.org/TR/xforms/