views:

260

answers:

1

Trying to help out a friend here... There is some output generated by an external tool that outputs xml nodes into a file. He needs to make this xml well-formed and apply a xsl stylesheet on it.

So we have b.xml (generated by the tool) and Encomp.xml that imports the contents of b.xml as an XML external entity like this (Create 3 xml files in the same folder if you want to try this out)

Encomp.xml

<?xml version="1.0"  encoding="utf-8"?>

<!DOCTYPE document [ <!ENTITY data SYSTEM 'b.xml'>]>
<Root-Element xmlns:log="http://log4net.sourceforge.net/"&gt;
    &data;
</Root-Element>

b.xml

<log:MyNode Name="Node1"/>
<log:MyNode Name="Node2"/>
<log:MyNode Name="Node3"/>

a.xml

<MyNode Name="Node1"/>
<MyNode Name="Node2"/>

Now the problem is that this approach works with content like a.xml (where the nodes are not qualified with a namespace) but doesn't work for b.xml.

My guess is that maybe the namespace is undefined at DOCTYPE line, it is only declared on the next line. How do I get this to work?

+1  A: 

b.xml needs to include the attribute xmlns:log="http://log4net.sourceforge.net/"

EDIT: Actually this doesn't really solve anything, the bottom line is that DTDs don't understand xmlns declarations and aliases anyway. Hence you just end up with other errors.

AnthonyWJones
b.xml is coming out of an external tool.. can't change its output. Anyway in which i can include the namespace in the Container xml to make this work.
Gishu
Ok.. so DTDs are not meant to contain namespace references.. I was hoping not.. but thanks anyways.
Gishu