Re: [xsl] asthetics vs convention for namespace prefixs

Subject: Re: [xsl] asthetics vs convention for namespace prefixs
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 Jul 2007 14:31:54 +0100
> I know I can't rely on the prefix being used,

actually you can, in XSLT2. the data model is quite explict that (a) the
prefix is stored in the model as part of the QName  (this part was also
essentially true but worded differently in XSLt1) and (b) an XSLT/XQuery
serialiser will not change the prefix, (Of course if the in-memory tree
is passed to some other system and only later serialised, then that
serialisation won't necessarily follow XSLt rules, and XSLT1 allowed an
XSLT system a lot more flexibility)

> but is it frowned upon to try and encourage a specific namespace
> prefix?

some people frown upon it, but they alos frown upon the use of prefixes
in attribute or element content as well.

If for example yu are generating XSLt (or schematron, or XSD schema or
...) that has something like select="x:foo/x:bar" then ensuring that an
ancestor element declares the appropriate namespace with exactly the
desired prefix "x" is an absolute requirement not just a question of
asthetics. 


Incidentally if you put
xmlns:xyz="http://schema.example.org/XYZ/Publishing"; up at the top of
your stylesheet on xsl:stylesheet element you can write

     <xsl:element name="xyz:{local-name(.)}"
          namespace="http://schema.example.org/XYZ/Publishing";
          xmlns:xyz="http://schema.example.org/XYZ/Publishing";>
          <xsl:copy-of select="@*" />

as

     <xsl:element name="xyz:{local-name(.)}"
          <xsl:copy-of select="@*" />

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread