Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Newbie: XML 2 XML and namespaces

Reply
Thread Tools

Newbie: XML 2 XML and namespaces

 
 
Mark Smits
Guest
Posts: n/a
 
      09-17-2003
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"
xmlnssi="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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-comslt">
<xslutput 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>


 
Reply With Quote
 
 
 
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      09-18-2003
In article <bka4bs$i6$(E-Mail Removed)1.nb.home.nl>,
Mark Smits <(E-Mail Removed)> 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/cretails_1"></xsl:apply-templates>

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

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

Patrick TJ McPhee
East York Canada
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Mark Smits
Guest
Posts: n/a
 
      09-21-2003
Thx, that worked perfectly

"Patrick TJ McPhee" <(E-Mail Removed)> wrote in message
news:bkckfe$m0p$(E-Mail Removed)...
> In article <bka4bs$i6$(E-Mail Removed)1.nb.home.nl>,
> Mark Smits <(E-Mail Removed)> 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/cretails_1"></xsl:apply-templates>
>
> % <xsl:template match="Details_1">
> % <xsl:value-of select="Klanten.Klantnummer"/>
> and
>
> <xsl:template match="cretails_1">
> <xsl:value-of select="cr:Klanten.Klantnummer"/>
> --
>
> Patrick TJ McPhee
> East York Canada
> (E-Mail Removed)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML::Parser and namespaces placebo.domingo@gmail.com Perl Misc 4 04-14-2006 11:53 PM
XML and namespaces =?ISO-8859-1?Q?Wilfredo_S=E1nchez_Vega?= Python 36 12-19-2005 01:39 PM
XML DTD Validation, namespaces and best practices johnmack@gmail.com XML 1 11-02-2005 11:03 PM
Clarification on XML parsing & namespaces (xml.dom.minidom) Greg Wogan-Browne Python 1 01-28-2005 03:19 AM
JSTL, XML and namespaces Digby Java 0 10-29-2003 07:54 AM



Advertisments