From W3C XForms Group Wiki (Public)
Jump to: navigation, search


Associating XML Documents with XForms using the XML-Stylesheet PI

W3C Working Group Note 1 November 2004

This version
Latest version
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.


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

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 (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"
    <name>John Doe</name>

The user_edit.xhtml document might look like:

<h:html xmlns:h=""
    <h:title>Edit user</h:title>
    <instance id="userinstance"/>
    <input ref="name"><label>Name</label></input>
    <input ref="homepage"><label>Homepage</label></input>


Associating Style Sheets with XML documents Version 1.0, W3C Recommendation, James Clark, editor, 29 June 1999.
Available at:
The latest version is available at:
XForms 1.0, W3C Recommendaton, M. Dubinko et al., eds., 14 October 2003.
Available at:
The latest version is available at: