[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Explicit document node creation

Subject: Explicit document node creation
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 10 Jan 2002 15:46:48 +0000
xsl dynamic node creation

Thinking about the whole sequence generation thing, it struck me that
what xsl:result-document actually does is create a node (just like
xsl:element etc.) - a document node. The sequence generated from its
content constructor forms the children of the document node, and the
attributes (format and href) give instructions about where that
document should go.

If you view it like this, I think that xsl:document is the more
appropriate name (because it ties in with xsl:element etc.). I also
think that you should be able to create documents that *don't* have a
destination indicated by an href attribute (I'll call these
anonymous documents).

The handling of an anonymous document depends on where the sequence
containing the anonymous document is produced:

  - if it's produced from the content of a variable-binding element,
    then the variable is bound to that document node (actually the
    sequence that includes that document node)

  - if it's produced from the content of an xsl:message, then the
    document is written to an implementation-defined destination for
    error messages (e.g. stderr)

  - if it's produced from the stylesheet as a whole, then the document
    is written to an implementation-defined destination for the result
    of the transformation (e.g. stdout)

Note that it should always be a dynamic error if there's more than one
anonymous document in a sequence.

For backwards compatability with XSLT 1.0 (and for convenience), if
the result sequence consists of documentless nodes, an anonymous
document should be implicitly created in certain circumstances:

  - by variable-binding elements, if they don't have a type attribute
    or have a type attribute with the value "document" (or whatever
    DataType expression is used to indicate a document node)

  - by xsl:message

  - by the stylesheet as a whole

>From this, there would be a constraint on the sequence constructors
for the stylesheet as a whole for and for xsl:message: they would need
to either consist entirely of document nodes (with different
destinations), or consist entirely of documentless nodes. If you
wanted to generate multiple documents, you'd need to use xsl:document
to create the main document as well as the subsiduary ones.

Also, you wouldn't be able to construct a document node while you were
in the middle of constructing another document. This is a very
different model from the 'tree of documents' approach of the current
XSLT 2.0 WD, the XSLT 1.1 WD and most extension elements. I'm not sure
whether this restriction makes it impractical (or any more impractical
than the current restriction that you can't create a secondary result
document within a variable).

It could mean additional processing because, for example, you couldn't
run through a bunch of nodes, creating a secondary result document for
each node at the same time as creating a link in the main result
document. You'd have to run through the same set of nodes twice in
order to create the two different bits of content.

On the other hand, that restriction (you can only do one thing at a
time) is true elsewhere in XSLT, so why shouldn't it be true when it
comes to creating documents?



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.