Re: adding a namespace declaration to result stylesheet?

Oliver Becker <[email protected]> Mon, 15 Sep 2003 10:49:00 +0200 (MEST)
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>
> >I believe with this <xsl:copy-of select="namespace::*" /> we can even
> >drop the <ns> element which is clearly just a work-around.
> >  
> >
> I believe the new version of XPath2 (and therefore XSLT 2?) does not 
> support namesace::*;
> anyone with better information on this? 

Yes, the namespace axis is deprecated in XPath 2.
That means we need different metastylesheets for XSLT-based implementations.

> If I recall the XML.COM? 
> article, there is some kind of workaround.

Without looking for this article, I think the pure XSLT2 solution is
something like this:
<xsl:for-each select="get-in-scope-namespaces(/*)">
   <xsl:namespace name="{.}">
      <xsl:value-of select="get-namespace-uri-for-prefix(/*, .)" />
   </xsl:namespace>
</xsl:for-each>

Note: get-in-scope-namespaces of the current (May 2) draft will be renamed
to get-in-scope-prefixes. 

> What do people think about the <ns> elements?  I personally think they 
> are the correct way to do things, but not really strongly.  In particular, 
> I think default (i.e., no prefix) Xpaths are a really dangerous idea. 

I'm afraid I don't understand your point.
XPath expressions that select elements from a certain namespace must use
prefixed names. If the targetted elements are in the null (empty) namespace
then clearly no prefix must be used.
The question is if Schematron needs this additional <ns> element to
declare namespaces. I don't think so. I cannot remember why <ns> was 
introduced:
- because nobody was aware of <xsl:copy-of select="namespace::*" /> ?
- because this solution didn't work with some XSLT processors?

Do you see any (semantic) difference between
<schema xmlns:p="urn:my-personal-namespace" ...>
and
<schema ...>
  <ns uri="urn:my-personal-namespace" prefix="p" />
  
?

Cheers,
Oliver

/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: [email protected]             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf