Altova Mailing List Archives

Re: [xsl] Namespace problem

From: Marc Schneider <mschneider@--------->
Date: 9/13/2004 9:37:00 PM
Dave -

Since WSDL files have QName in attributes, the namespace prefix in the 
attribute can be any in-scope namespace. This deviation from the XPath data 
model makes it very difficult to process WSDL files.


At 04:27 PM 9/13/2004, you wrote:
> Hello -
> I may have spoken too soon when I said that using current() did the
> This apparently works in XalanJ, but XalanC v1.7 appears to have a
> with namespace::* and doesn't evaluate namespace::*[starts-with(name(),
> substring-before(current()/parent::node()/@name,':'))] correctly.
> Unfortunately, I need to support XalanC v1.7, does anyone know of a way
> resolve a namespace URI from the prefix in XalanC 1.7?

This is a case where Xalan-C deviates from the XPath data model, and does
not have a namespace node for every in-scope namespace on every element.
The following stylesheet produces the desired result:

<?xml version="1.0"?>

<xsl:output encoding="utf-8" />

<xsl:template match="wsdl:operation">
  <xsl:element name="operation">
      <xsl:when test="contains(parent::node()/@name,':')">
          <xsl:variable name="ns"
select="substring-before(parent::node()/@name, ':')" />
        <xsl:attribute name="portType_nspc">
            <xsl:when test="contains(parent::node()/@name,':')">
              <xsl:value-of select="namespace::*[name() = $ns]"/>
        <xsl:attribute name="portType_nspc"/>


I've been tempted numerous times to fix this deviation, but the cases
where this has caused a problem have been extremely rare, and the cost in
memory overhead is considerable in many cases.



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.