Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

xmlns in root element

Former Member
0 Kudos

When converting exchange rates xml from http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

I'm getting problem with xmlns in root element.

CALL TRANSFORMATION triggers CX_XSLT_ABAP_CALL_ERROR, but only if there is xmlns attribute in first line in input xml:

<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">

Without this xmlns=..... (or when modifying e.g. abcxmlns= ) works following xslt fine:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">

<xsl:strip-space elements="*"/>

<xsl:template match="/">

<xsl:copy>

<xsl:apply-templates/>

</xsl:copy>

</xsl:template>

<xsl:template match="Cube/Cube">

<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">

<asx:values>

<ROOT2>

<xsl:value-of select="@time"/>

</ROOT2>

<ROOT1>

<xsl:apply-templates select="Cube"/>

</ROOT1>

</asx:values>

</asx:abap>

</xsl:template>

<xsl:template match="Cube/Cube/Cube">

<loop>

<AMOUNT>

<xsl:value-of select="1"/>

</AMOUNT>

<CCYCODE>

<xsl:value-of select="@currency"/>

</CCYCODE>

<VALUE>

<xsl:value-of select="@rate"/>

</VALUE>

</loop>

</xsl:template>

</xsl:transform>

I'd appreciate if someone migh advise me how to alternate the xslt or tell me what the xmlns in input does.

Cheers

Edited by: Viktor Kunc on Sep 29, 2008 3:25 PM

2 REPLIES 2

Former Member
0 Kudos

Hi Viktor,

  I have same problem. do you solve it?

thanks,

  mauro

0 Kudos

If a namespace is specified on root level, it propagates down to all children, see:

http://www.w3.org/TR/REC-xml-names/

The namespace is part of a name. So, if you have an element <Cube> as child of the root element <root xmlns="http://www.gesmes.org/xml/2002-08-01">, then

<xsl:apply-templates select="Cube"/>

won't be applied, since the qualified name of the element is not Cube but {http://www.gesmes.org/xml/2002-08-01}Cube

If you want the XSLT to work with and without namespace equally well, you have to work with local names in XPath expressions:

<xsl:apply-templates select="local-name() = 'Cube'"/>

The same holds for all XPath functions working with element names.

Usually, however, the namespace is part of the contract with the client and is

  • either obligatory to be used
  • or obligatory to be omitted.

But not both.

Regards,

Rüdiger