Newbie: XML 2 XML and namespaces

Mark Smits

Usenet Archive
Joined
Sep 17, 2003
Messages
2
Reaction score
0
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>
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
% 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"/>
 

Mark Smits

Usenet Archive
Joined
Sep 17, 2003
Messages
2
Reaction score
0
Thx, that worked perfectly :)

Patrick TJ McPhee said:
% 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top