XSLT and XML namespace issue

Discussion in 'XML' started by pc.candy@gmail.com, Jun 22, 2007.

  1. Guest

    Hi there

    I'm having some difficulty with transforming xml data with more than
    one namespace defined in the xml.
    I'm able to bring back some values of the xml but not others in
    another namespace?
    For example from the following xml data I can bring bring back the
    value for <address> but I can't seem to figure out how to bring back
    the <CountryNameCode> which is in another namespace.
    I'm not able to manipulate the xml output, but I'm able to customise
    the xslt.
    Below is the example xml and the xslt I'm trying to use.

    /******************* XML data *********************************/

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://earth.google.com/kml/2.0">
    <Response>
    <name>ABC Compnay</name>
    <Status>
    <code>200</code>
    <request>geocode</request>
    </Status>
    <Placemark id="p1">
    <address>123 Harris St, Pyrmont, NSW 2009, Australia</address>
    <AddressDetails Accuracy="8"
    xmlns="urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0">
    <Country>
    <CountryNameCode>AU</CountryNameCode>
    </Country>
    </AddressDetails>
    </Placemark>
    </Response>
    </kml>

    /********************************************************/

    /**************** XSLT I'm using *********************/

    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:asx="http://www.sap.com/abapxml" xmlns:kml="http://
    earth.google.com/kml/2.0"
    xmlns:AddressDetails="urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0"
    version="1.0">
    <xsl:template match="/">
    <asx:abap version="1.0">
    <asx:values>
    <GEOCODE>
    <STREET>
    <xsl:value-of select="kml:kml/kml:Response/kml:placemark/
    kml:address"/>
    </STREET>
    <COUNTRY>
    <xsl:value-of select="kml:kml/kml:Response/kml:placemark/
    kml:AddressDetails/AddressDetails:Country/
    AddressDetails:CountryNameCode"/>
    </COUNTRY>
    </GEOCODE>
    </asx:values>
    </asx:abap>

    </xsl:template>

    </xsl:transform>

    /**********************************************************/

    Does anyone have any ideas to what I should change in the XSLT??

    Thanks.
     
    , Jun 22, 2007
    #1
    1. Advertising

  2. schrieb:
    > <kml xmlns="http://earth.google.com/kml/2.0">

    [...]
    > <AddressDetails Accuracy="8"
    > xmlns="urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0">


    Here you use an AddressDetails element from the
    urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0 namespace. Is taht what you want?

    [...]
    > <xsl:value-of select="kml:kml/kml:Response/kml:placemark/
    > kml:AddressDetails/AddressDetails:Country/
    > AddressDetails:CountryNameCode"/>


    See above: AddressDetails is not in the http://earth.google.com/kml/2.0
    namespace.

    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Jun 22, 2007
    #2
    1. Advertising

  3. Guest

    On Jun 22, 5:40 pm, Johannes Koch <> wrote:
    > schrieb:
    >
    > > <kml xmlns="http://earth.google.com/kml/2.0">

    > [...]
    > > <AddressDetails Accuracy="8"
    > > xmlns="urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0">

    >
    > Here you use an AddressDetails element from the
    > urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0 namespace. Is taht what you want?
    >
    > [...]
    >
    > > <xsl:value-of select="kml:kml/kml:Response/kml:placemark/
    > > kml:AddressDetails/AddressDetails:Country/
    > > AddressDetails:CountryNameCode"/>

    >
    > See above: AddressDetails is not in thehttp://earth.google.com/kml/2.0
    > namespace.
    >
    > --
    > Johannes Koch
    > In te domine speravi; non confundar in aeternum.
    > (Te Deum, 4th cent.)


    Hi Johannes

    Yes I do want the AddressDetails element in that namespace also.
    What xslt should I use to transform this?
     
    , Jun 23, 2007
    #3
  4. schrieb:
    > What xslt should I use to transform this?


    You have to correct your _XML_ file. As I wrote: currently the
    AddressDetails is not in the http://earth.google.com/kml/2.0 namespace.
    --
    Johannes Koch
    Spem in alium nunquam habui praeter in te, Deus Israel.
    (Thomas Tallis, 40-part motet)
     
    Johannes Koch, Jun 23, 2007
    #4
  5. Johannes Koch schrieb:
    > schrieb:
    >> What xslt should I use to transform this?

    >
    > You have to correct your _XML_ file. As I wrote: currently the
    > AddressDetails is not in the http://earth.google.com/kml/2.0 namespace.


    .... because you set the default namespace for this element and its child
    elements to urn:eek:asis:names:tc:ciq:xsdschema:xAL:2.0
    --
    Johannes Koch
    Spem in alium nunquam habui praeter in te, Deus Israel.
    (Thomas Tallis, 40-part motet)
     
    Johannes Koch, Jun 23, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    694
    Stylus Studio
    Aug 3, 2004
  2. Replies:
    1
    Views:
    428
    David Carlisle
    Dec 15, 2004
  3. Replies:
    4
    Views:
    684
  4. Rajesh
    Replies:
    0
    Views:
    396
    Rajesh
    Jul 18, 2006
  5. Rajesh
    Replies:
    1
    Views:
    728
    Martin Honnen
    Jul 19, 2006
Loading...

Share This Page