Newbie: XML 2 XML and namespaces

Discussion in 'XML' started by Mark Smits, Sep 17, 2003.

  1. Mark Smits

    Mark Smits Guest

    Hi, newbie needs help...

    My from XML has a namespace defined with no prefix. I tried to create a XSL
    that converts this from XML to another one. I tried it without that
    namespace and with that namespace. No matter what I try, I can't get this to
    work.

    The only time I succeed is when deleting the namespace in the from XML file.
    But that's no option...

    Inserted below are a sample XML and XSL file and both have the name spaces.
    Can someone please point me in the right direction: how to get the XSL to
    work with that namespace declaration in the XML.

    Thanks,
    Mark

    =============================================
    XML
    =============================================
    <?xml version="1.0" encoding="UTF-8" ?>
    <Report xmlns="urn:crystal-reports:schemas"
    xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xsi:schemaLocation="urn:crystal-reports:schemas Untitled.xsd" >
    <Details_1 SectionNumber="0">
    <Klanten.Klantnummer
    FieldName="{Klanten.Klantnummer}">ALFKI</Klanten.Klantnummer>
    <Klanten.Bedrijf FieldName="{Klanten.Bedrijf}">Alfreds
    Futterkiste</Klanten.Bedrijf>
    <Klanten.Contactpersoon FieldName="{Klanten.Contactpersoon}">Maria
    Anders</Klanten.Contactpersoon>
    <Klanten.Functie
    FieldName="{Klanten.Functie}">Vertegenwoordiger</Klanten.Functie>
    <Klanten.Adres FieldName="{Klanten.Adres}">Obere Str. 57</Klanten.Adres>
    <Klanten.Plaats FieldName="{Klanten.Plaats}">Berlijn</Klanten.Plaats>
    <Klanten.Provincie FieldName="{Klanten.Provincie}"></Klanten.Provincie>
    <Klanten.Postcode FieldName="{Klanten.Postcode}">12209</Klanten.Postcode>
    <Klanten.Land FieldName="{Klanten.Land}">Duitsland</Klanten.Land>
    <Klanten.Telefoonnummer
    FieldName="{Klanten.Telefoonnummer}">030-0074321</Klanten.Telefoonnummer>
    <Klanten.Faxnummer
    FieldName="{Klanten.Faxnummer}">030-0076545</Klanten.Faxnummer>
    </Details_1>
    </Report>
    =============================================
    XSL
    =============================================
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
    xmlns="urn:crystal-reports:schemas"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:eek:utput method="xml"/>
    <xsl:template match="/">
    <xsl:apply-templates select="/Report/Details_1"></xsl:apply-templates>
    </xsl:template>
    <xsl:template match="Details_1">
    <xsl:value-of select="Klanten.Klantnummer"/>
    </xsl:template>
    </xsl:stylesheet>
     
    Mark Smits, Sep 17, 2003
    #1
    1. Advertising

  2. In article <bka4bs$i6$1.nb.home.nl>,
    Mark Smits <> wrote:

    % My from XML has a namespace defined with no prefix.

    This doesn't mean the corresponding tags in XSL need have no prefix.

    [...]

    % <xsl:stylesheet version="1.0"
    % xmlns="urn:crystal-reports:schemas"
    Try

    xmlns:cr="urn:crystal-reports:schemas"

    [...]

    % <xsl:apply-templates select="/Report/Details_1"></xsl:apply-templates>
    Try
    <xsl:apply-templates select="/cr:Report/cr:Details_1"></xsl:apply-templates>

    % <xsl:template match="Details_1">
    % <xsl:value-of select="Klanten.Klantnummer"/>
    and

    <xsl:template match="cr:Details_1">
    <xsl:value-of select="cr:Klanten.Klantnummer"/>
    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Sep 18, 2003
    #2
    1. Advertising

  3. Mark Smits

    Mark Smits Guest

    Thx, that worked perfectly :)

    "Patrick TJ McPhee" <> wrote in message
    news:bkckfe$m0p$...
    > In article <bka4bs$i6$1.nb.home.nl>,
    > Mark Smits <> wrote:
    >
    > % My from XML has a namespace defined with no prefix.
    >
    > This doesn't mean the corresponding tags in XSL need have no prefix.
    >
    > [...]
    >
    > % <xsl:stylesheet version="1.0"
    > % xmlns="urn:crystal-reports:schemas"
    > Try
    >
    > xmlns:cr="urn:crystal-reports:schemas"
    >
    > [...]
    >
    > % <xsl:apply-templates select="/Report/Details_1"></xsl:apply-templates>
    > Try
    > <xsl:apply-templates

    select="/cr:Report/cr:Details_1"></xsl:apply-templates>
    >
    > % <xsl:template match="Details_1">
    > % <xsl:value-of select="Klanten.Klantnummer"/>
    > and
    >
    > <xsl:template match="cr:Details_1">
    > <xsl:value-of select="cr:Klanten.Klantnummer"/>
    > --
    >
    > Patrick TJ McPhee
    > East York Canada
    >
     
    Mark Smits, Sep 21, 2003
    #3
    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. ravi sankar
    Replies:
    2
    Views:
    387
    abdul bari
    Aug 27, 2003
  2. Digby

    JSTL, XML and namespaces

    Digby, Oct 29, 2003, in forum: Java
    Replies:
    0
    Views:
    593
    Digby
    Oct 29, 2003
  3. Omar
    Replies:
    4
    Views:
    18,144
    Patrick TJ McPhee
    Jun 21, 2005
  4. Greg Wogan-Browne
    Replies:
    1
    Views:
    813
    Uche Ogbuji
    Jan 28, 2005
  5. Replies:
    56
    Views:
    733
    alex23
    Dec 27, 2012
Loading...

Share This Page