RE: [xsl] Simple XML -> XML transform problem, possibly namespace related

Subject: RE: [xsl] Simple XML -> XML transform problem, possibly namespace related
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 16 May 2004 10:32:32 +0800
At 2004-05-15 21:15 -0500, Pieter Reint Siegers Kort wrote:
Thanx, Ken, you opened my eyes, now it works like a charm!! :-)

I had it worked out also if I did change the default namespace in the XML
source, but didn't know that I could add a prefix in my XSL.

One Q still: I wonder why the source XML doesn't use a prefix - should it?

It needn't ... and not using one is the practice of using the default namespace. Here is your data from your earlier message:


<?xml version="1.0" encoding="UTF-8"?>
<job xmlns="http://ns.real.com/tools/job.2.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://ns.real.com/tools/job.2.0
http://ns.real.com/tools/job.2.0.xsd";>
  <enableTwoPass type="bool">false</enableTwoPass>
  <clipInfo>
    <entry>
      <name>Copyright</name>
      <value type="string">(C) 2004</value>
    </entry>
  </clipInfo>
  <inputs>
    <input xsi:type="avFileInput">
      <filename type="string"></filename>
    </input>
  </inputs>
  <parOutputs>
    <output>

The xmlns="URI" declares the associated namespace URI for element types that have no namespace prefix.

Note that attributes never use the default namespace: an unprefixed attribute is an attribute in no namespace ... it isn't even in the namespace of the element to which it is attached, though most vocabularies do specify behaviours for unprefixed attributes attached to elements in the vocabulary.

An important reminder, though, is that proper namespace-aware processing is based solely on the URI and not on the prefix: you could use "j:" in your stylesheet and "baboon:" in your instance and the stylesheet will still work if the namespace prefixes are mapped to the same URI strings.

I hope this helps.

................. Ken

--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Next: 3-day XSLT/XPath; 2-day XSL-FO - Birmingham, UK June 14,2004

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread