"Seegrid will be due for a migration to confluence on the 1st of August. Any update on or after the 1st of August will NOT be migrated"

About

Page to discuss issues using XSLT to transform GML-derived pages in particular.

Default Namespaces

XSLT does not match with default namespaces:
  • I think by the time the tree arrives at the XSLT processor, default namespaces have already been applied to the nodes,
  • an XML file with no default namespace specified will put unqualified elements in the 'unnamed' namespace

This is mentioned in:
  • http://www.topxml.com/people/bosley/defaultns.asp
  • http://www.biglist.com/lists/xsl-list/archives/200010/msg00200.html says it very clearly:
    If an element or attribute in the source document is in a namespace (whether default or prefixed), your stylesheet must include a namespace declaration corresponding to the same namespace and it must use a prefix as well (whatever you want). Even if your stylesheet itself has a default namespace, that namespace will only be in effect for unprefixed element names in the stylesheet, but not for names in XPath expressions or XSLT patterns.

Practical Implications

Stylesheets are effectively anchored to the XML they are meant to process in that they must explicitly declare a namespace for the URI of the default namespace in the original XML. This is probably not a big deal for the current Infosrvices demonstrator.

It makes it hard to define reusable stylesheet components that could be applied to any GML application schema.

Corollary 1

There is a natural correspondance between Feature Types and presentation (stylesheets) so the task is not so much to create (very ordinary presentation) generic stylesheets as to effectively and efficiently manage the creation and dissemination of Feature Type specific stylesheets.

Corollary 2

Stylesheets can be built around structural patterns - and can ignore actual tag names - so with the addition of some sort of "persistent binding" in a catalog, a stylesheet can be declared to be suitable for a Feature Type without knowing explicitly what the tags and namespaces are.

Corollary 3

Inheritance in Feature Types is critical to be able to effectively constrain structural patterns to allow stylesheets to exploit them.

-- RobAtkinson - 09 Nov 2004

One way to think of this limitation, if you're a programmer, is to think of W3C XML Schema as providing inheritance but not polymorphism.

You can't refer to a base type such as gml:FeatureCollection and have the stylesheet legally apply to a subtype xmml:FeatureCollection.

Hence, you can't write generic stylesheets.

Schema Implications

XSLT does not understand XML Schema.

Following Substitutions and References

Say we have some XML with a relative ref back in the file, like:
  <featureMember>
    <GeochemSpecimen gml:id="WA_1_139459">
      <gml:name>139459</gml:name>
      <gml:position xlink:href="urn:x-seegrid:definition:gml:NilReason:unknown"/>
      <material>rock</material>
      <relatedObservation>
        <GeochemMeasurement gml:id="WA_1_139459_Ag">
        <gml:position xlink:href="../../../gml:position"/>

We want a way to process the relative reference "../../../gml:position" with the template that processes a standard gml:position.

Unfortunately, you can't construct dynamic paths - select targets have to be literals.

What's New in XSLT 2.0 describes how XSLT 2.0 includes the conversion of result-tree fragments to node-sets which is currently only available in XSLT 1.0 using a (common) extension.

So, with more work, we can either use node-set() or nodeset() extensions (depending on processor) or wait for XSLT 2.0 in favourite processors.

The document idea

I had the idea and PaulDaisey also suggested using the document() function to construct a destination. This doesn't work either because you can't get a reference to the current document. You can refer explicitly to a known document or to the current stylesheet.

It is possible that by passing parameters into the stylesheet to name the current document, we could use this approach.

Default Values

Topic revision: r6 - 15 Oct 2010, UnknownUser
 

Current license: All material on this collaboration platform is licensed under a Creative Commons Attribution 3.0 Australia Licence (CC BY 3.0).