Altova Mailing List Archives

[xsl] how to reflect on the namexpaces URIs and prefixes in XSLT?

From: Gunther Schadow <gunther@---------------------->
Date: 2/11/2002 6:41:00 AM

I am working on a XSLT dealing with XML Schemas. I generate
certain Schema thingies, like complexType and simpleType
and other elements. Within those, I need to deal properly
with the XML Schema "targetNamespace". For instance, if
the ancestor schema node of the input document has this


now if I generate a xsd:complexType definition for a type
called 'foo' I will generate:

 <xsd:complexType name='foo'/>

if I refer to such types defined in the schema, I have to
do something like this:

 <xsd:element name='thing' type='v3dt:foo' />

Now the questions:

- how do I query for the active namespace prefix declarations
  in the input document?

  Apparently (in saxon at least) the document that I can see
  with <copy-of select='$root'/> where <xsl:variable name='root'
  select='/'/> doesn't contain any xmlns:... attributes, at least
  not at the point of my XSLT execution where I need them.

- even if I find those xmlns:... attributes (which I do, sort of,
  in the root template of the XSLT), how do I query those? I can see
  the xslns attributes show up when I do

  <xsl:copy-of select='$root//xsd:schema'/>

  but as soon as I'm trying to grab them specifically, e.g.,

  <xsl:for-each select='$root//xsd:schema/@*'/>

  I'm not seeing any of the xmlns ones. They only show up if
  anything is actually using the namespace in the output, but
  how do I know what namespace prefix the xsd:schema/@targetNamespace
  is bound to?

It sounds like XSLT is making namespace prefix declarations a
special thing (which is O.K.) but it doesn't provide any special
mechanisms by which one could dynamically work with the namespaces
used by an input document. Are there any workarounds?


Gunther Schadow, M.D., Ph.D.                    gschadow@xxxxxxxxxxxxxxx
Medical Information Scientist      Regenstrief Institute for Health Care
Adjunct Assistant Professor        Indiana University School of Medicine

XSL-List info and archive:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.