Subject: Re: XPointers and XSL Patterns From: James Clark <jjc@xxxxxxxxxx> Date: Wed, 02 Sep 1998 13:14:50 +0700 |
James Tauber wrote: > > This is a very rough attempt to cast the first half of the examples from the > current WD-xptr into XSL patterns along with some brief notes on how XSL > patterns would need to be expanded. One problem is that square brackets aren't allowed in URI references (see RFC 2396), but XPointers need to be able to go inside URI references (both in queries and fragments). You can of course % escape them, but that's not a very attractive option. XSL could change from foo[bar] to something like select(foo,bar). The obvious (to me anyway) syntax for PIs in XSL patterns is pi(foo) or pi(*) where the argument is the target following the syntax for ids and attributes. > ancestor(1,#element,N,1).(1,DIV) <!-- I'll infer existence of current > node --> > > note: In XSL terms, you've got to think of this as the DIV element whose > first descendent is the first element ancestor of the current note with > attribute N = 1. Whew! So we need descendant as well as child qualifiers > along with instance numbers on both descedant and ancestor: > > DIV[descendant(*[1,./ancestor(*[1,attribute(N)='1'])])] I would do something like ancestors(*[attribute(N)='1'])[-1]/ancestor(div) That is, I think of "/" in XSL patterns as being equivalent to "." in current XPointer syntax, and an unadorned element type name in XSL patterns is equivalent to child() in XPointer syntax. Some other possible syntaxes: instance(select(ancestors(*), attribute(N)='1'), -1)/ancestor(div) ancestors(*)!select(attribute(N)='1')!-1!ancestor(div) ancestors(*)/select(attribute(N)='1')/-1/ancestor(div) (It's -1 because the index in the ancestor XPointer is in reverse of document order.) I believe a unification is technically possible. I think the important things for XSL (in order of priority) are: - <xsl:template match="foo"> can be used to match all elements of type foo. This kind of pattern accounts for very large percentage of patterns. - <xsl:template match="foo/bar"> can be used to match all bar elements with foo children. This is the next most important kind of pattern. I could live with an alternative character for "/" but it should be a single character. - <xsl:template match="foo//bar"> can be used to match all bar elements with a foo ancestor. This is almost as important as foo/bar. It doesn't have to be "//" but it needs to be easy. - * should be useable as a wildcard element - <xsl:process select="foo"> can be used to select the children of the current node that are of type foo. James (As always in this forum, speaking for myself alone, not for XSL WG.) XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
XPointers and XSL Patterns, James Tauber | Thread | Re: XPointers and XSL Patterns, James Tauber |
XPointers and XSL Patterns, James Tauber | Date | FW: XSL - Loss to braille style she, Pawson, David |
Month |