[
Lists Home |
Date Index |
Thread Index
]
Jeff Rafter wrote:
>>> Say the test was /foo/bar/[baz2="test"]/baz1
>>>
>>> <foo>
>>> <bar>
>>> <baz1/>
>>> <baz2>test</baz2>
>>> <baz3/>
>>> </bar>
>>> </foo>
>>>
>>> If your schema stated that the children were (baz1,baz2,baz3)
>>> wouldn't you have enough information to know to surrender when
>>> you reached baz3?
>>
>
> Essentially in order to make a useful case of this (surrendering at
> baz3) you would need to cache all previous events so that they could
> be replayed when the predicate's boolean value was determined.
> Unfortunately that solution doesn't win much against the DOM or other
> tree based models.
>
> The *trick* is to know when you reach baz1 so that you can begin doing
> interesting things with the chain of events as they happen. Now, the
> Schema Assisted Sipping that you mention might broaden the cases that
> predicates would be useful but they are still limited. For example if
> your schema asserted (as you say) that the content model of bar be
> (baz1, baz2, baz3) and that baz2="test" always-- then you could
> "surrender" at the point of baz1 by starting with the assumption of
> validity. If the document turns out to not be valid you could raise
> some special error that says essentially-- hey we assumed this was
> valid and it isn't so we don't know if we reported the right thing or
> not.
>
> There is still a group of solvable predicates too, like:
>
> /foo/bar[baz2="test"]/baz3
>
> Here the predicate's boolean value will be known before the
> startElement for baz3 is reached. The question is: is it worth
> defining a constraint for this in plain language or in grammar, or
> should predicates be nixed entirely? If we aim for defining the
> constraint then I would suspect that we will find a wealth of
> information on this exact subject on the STX list (as Christian
> mentioned)-- but ultimately it appears that they decided no such
> constraint would appear in their language. In XML Schema's stripped
> down XPath, predicates are not permitted.
IMO we should at least allow abbreviated positional predicates:
/foo/bar[2]
Going further, I think we could come up with a formula that allows us to
decide for most predicates whether or not they can be decided with N or
less SAX event look-ahead.
At least I think it's worth trying to concoct such a formula, and if no
one beats me to it, I'll give it a whirl when I get a chance.
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
Use CSS to display XML - http://www.ibm.com/developerworks/edu/x-dw-x-xmlcss-i.html
Full XML Indexes with Gnosis - http://www.xml.com/pub/a/2004/12/08/py-xml.html
Be humble, not imperial (in design) - http://www.adtmag.com/article.asp?id=10286
UBL 1.0 - http://www-106.ibm.com/developerworks/xml/library/x-think28.html
Use Universal Feed Parser to tame RSS - http://www.ibm.com/developerworks/xml/library/x-tipufp.html
Default and error handling in XSLT lookup tables - http://www.ibm.com/developerworks/xml/library/x-tiplook.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/
The State of Python-XML in 2004 - http://www.xml.com/pub/a/2004/10/13/py-xml.html
|