[xslt] parsing xml-files



Hello,

I've got a question about the use of prefixes in an XML-file when parsing it
to an HTML-doc.
When I looked at the documentation in the W3 pages, it seemed that using a
namespace prefix is not obligated.  It even seems so that when you define a
namespace in a node, all childnodes use this namespace, unless you declare a
new one, or use a prefix for a node.  This means a xml like the following is
well formed:

<?xml version='1.0' encoding='utf-8'?>
<record xmlns="http://namespace_1/">
  <data>
    <person xmlns="http://namespace_2/">
      <name>vloeberghs</name>
      <firstname>kris</firstname>
    </person>
  </data>
</record>

The nodes <record> en <data> should make use of namespace_1, the nodes
<person>, <name> and <firstname> should make use of namespace_2.  According
to what W3 says, this is a wellformed XML-doc.

My question is the following:
Howcome I'm unable to parse this document withoud adding prefixes (like the
following)?

<?xml version='1.0' encoding='utf-8'?>
<xsi:record xmlns="http://namespace_1/">
  <xsi:data>
    <person pers:xmlns="http://namespace_2/">
      <pers:name>vloeberghs</pers:name>
      <pers:firstname>kris</pers:firstname>
    </pers:person>
  </xsi:data>
</xsi:record>

The actual problem is that my XML-doc comes from the server looking like my
first example.  Is there any possibility using the libxml or libxslt
libraries to solve this problem.  Maybe there is a way of parsing this file,
or maybe I can automatically add these prefixes.  I'm just guessing.  Can
anybody help me with this please?

kris





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]