Skip to Content
author's profile photo Former Member
Former Member

xmlns in root element

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:

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:

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">

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2012 at 11:53 AM

    Hi Viktor,

    I have same problem. do you solve it?

    thanks,

    mauro

    Add a comment
    10|10000 characters needed characters exceeded

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

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

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.