Re: [xsl] character entities

Subject: Re: [xsl] character entities
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Wed, 21 Nov 2001 12:25:12 +0100
David Carlisle <davidc@xxxxxxxxx> wrote:
> > [general entities] should be abolished anyway...
> why? they make life more interesting...

Uh, my life is interesting enough without them...

> > ...replace them by <nag:refer item="e04BL-a"/>
Well, you can always use a two pass approach. If implementing
the first pass (expanding the references) in XSLT is a performance
issue, do it as a SAX handler.

> a) you lose a lot of validation
> checks if you do that as you would have to basically allow nag:refer
> everyhere, and it would be able to refer to any content.
I doubt this. I did not bother to understand the example you gave,
but since you did not mention that you have to put not-well formed
XML into the entities, i assume they have some semantic. You can
use nag:ref-formula, nag:ref-constraint etc. instead of the general
nag:refer and allow the elements only in the context where they make
sense. The referenced elements can then have a well defined internal
structure. This will make the dictionary more complicated and thwart
automagic dictionary generation, but so what.

> b) The logic in the stylesheet becomes muct more difficult.
> ... this sort of logic becomes _really_ hard to maintain if in _every_ step
> of every Xpath expression you have to take account of the fact that
> the elements you are looking for might not be in the tree directly but
> only in the trees referred to by  <nag:refer
If the references become somewhat standardized, you should be able to
put this logic into reusable templates.

Don't complain about that such a standardisation is not possible.
You can always refine your data model. It's like moving from FORTRAN
to PASCAL :-)

> That's the nice thing about entities: when walking over the
> tree you dont need to care if the text is directly in the document or in
> an entity

Well, there are things i take issue with:
1. Entities are multi-role, each with a quite different semantic:
  - text replacement (including by not well-formed XML fragments)
  - physical structure of the document
  - reference to non-XML information
  This is bad.
2. Entities definitions require DTDs which also may provide a structure
  definition. How do you mix this and a structure definition by a
3. Entity related stuff cannot be generated by XSLT (though this could
  be fixed by inventing xsl:entityref and DTD generating elements).

My vision is:
- Abolish entities and notations, except perhaps aliases for character
- Do physical structuring of a XML document by a <xml:include href=.../>
  element, which should probably be handled at the parser level by default
  (can be switched off).
- Abolish DTDs as such and use XSchema (or a XML-ified DTD version for
  simple cases) to declare validity constraints.
- Better leverage of URIs for all kind of references. Specify a catalog
  URI to replace PUBLIC ids. Universally use URIResolvers in XML
  related software.
Text replacement and reference to non-XML information (like binary images)
would be handled at the XSLT level and could use either standardized
markup (xlink and perhaps xinclude stuff) or customized markup.
This would separate conceps which are currently muddled toghether and
make for a more modular system of XML-related standards.


 XSL-List info and archive:

Current Thread