[plt-scheme] Re: matching XML types
In a message dated Sun, 11 Aug 2002 1:13:14 PM Eastern Standard Time, markj at cloaked.freeserve.co.uk writes:
> > [...] With SXML, I'm pretty sure one could, off-the-shelf, use PLT's
> > match. [...]
>
> Indeed, you can.
One difference though is the semantics of pattern matching for attributes:
with PLT's match, if you give a pattern like (@ (attr1 ,v1) (attr2 ,v2)),
both attr1 and attr2 must be present in the element being matched--and you
can't give a default value (that I know of) if they are absent. As well,
these can be the *only* attributes on that element. I allow pattern matching
of attributes where the selected attributes must be either present in the
element or be "defaulted"-- and the element may include other attributes.
This represents a distinct philosophy about the role attributes in XML.
I do not treat of matching elements in the same way.
> > At the same time, there will soon be an alternative available-- pattern
> > matching based on the regular expression pattern matching of XDuce.
>
> Based on XDuce? So not XDuce?
Well, XDuce is not, after all, provided with a Scheme syntax. Mainly, I meant
that it will be something of a transliteration of the XDuce syntax into something
more consistent with Scheme and the syntax of WebIt!'s representation of XML.
But the matching of attributes in my rendition will be similar in both syntax
and behaviour to the current approach.
> > The predicate a:link? will fail to match (link "some text") and (b:link
> > "another element")-- because both the predicates and the
> pattern matching
> > system use the expanded names for all tag comparisons.
>
> What about link?
One has to recall the expanded names for the elements which these functions
are constructing:
One can define a variety of "similar" tags, where constructors are mapped to expanded
names as follows:
>> a:link ==> link
>> link ==> {urn:place1}:link
>> b:link ==> {urn:another-place}:link
link? will match (link "... contents ..."). It will not match something constructed
with a:link or b:link-- which would produce a locally named element (from a:link) or
an element in a different namespace (from b:link).
Jim