Re: [xsl] Content constructors and sequences

Subject: Re: [xsl] Content constructors and sequences
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 9 Jan 2002 22:32:20 +0000
Mark Nahabedian wrote:
> Quoting Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>:
>> Putting it another way, sequence constructors can either construct
>> sequences holding a number of documentless nodes, or a sequence
>> containing any kind of items. It's a dynamic error if the result
>> sequence contains documentless nodes and either simple typed values
>> or pre-existing nodes.
>
> Why is it that the sequence itself can't be considered to be a
> document?

There are several sorts of answers to that question. At a high level,
it's because of the way the XML Infoset and XML Schema describe XML
documents - documents contain element and attribute information items
which have values which are of different types. Text nodes do not have
types, and of course they get merged together. More practically, a
sequence can't be considered a document because a document cannot
contain nodes from other documents, so treating them like documents
would mean that sequences could only contain nodes from that document,
rather than nodes from other documents. And that would make certain
operations hard to handle because you'd lose context information (all
the nodes in the sequence would have this document as their parent,
for example).

>> First, you could just not worry about it. An attribute's name is a
>> xs:QName, which incorporates the namespace URI so there's no
>> problem getting that namespace URI. If an attribute's typed value
>> is a xs:QName or a list of xs:QNames (which it should be if the
>> values have are qualified names), then each of those xs:QName
>> values must have its own namespace URI accessible as well. So an
>> attribute doesn't need namespace nodes. (Possibly - can you think
>> of some examples where you need to access a namespace node given
>> you have access to a QName?)
>
> This is admittedly a stretch, but the value of the attribute could
> be a string containing QNames, for example, an XPath expression.
> Then again, one could probably construct such a degenerate case in
> 1.0 as well.

That's a good point - an attribute value that contains QNames in some
nested way. On the other hand, the parentless attribute that you're
trying to get namespace information from is a parentless attribute
that you've created elsewhere in the same stylesheet. If you're having
to re-parse and understand information through an attribute value,
then you should probably be redesigning your stylesheet! :)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread