[jdom-interest] Why does my namespace alias disappear?

Hainer, Neil hainern at jivanet.net
Thu Jan 29 15:53:26 PST 2004


Hi,
 
I have the following program that reads in an xml file, builds a Jdom tree and writes it out using XMLOutputter:
 
import java.util.*;
import java.io.*;
 
import org.jdom.*;
import org.jdom.input.DOMBuilder;
import org.jdom.input.SAXBuilder;
import org.jdom.output.DOMOutputter;
import org.jdom.output.XMLOutputter;
 
class TestXYZ
{
    TestXYZ
    {
    }
 
    public static void main( String[] args )
    {
 
 
        String fileName  =  null;

        fileName = args[0];
 
 try
 {
            SAXBuilder saxBuilder = new SAXBuilder();
            Document jdomDocument1 = saxBuilder.build( fileName );
 
           XMLOutputter outp = new XMLOutputter();
          outp.setTextTrim(true);
          outp.setIndent("  ");
          outp.setNewlines(true);
          outp.output( jdomDocument1, new BufferedOutputStream(new FileOutputStream( fileName + "FromJdom.xml" )) );
 
 }
        catch(JDOMException jde)
        {
            jde.printStackTrace(System.err);
           System.exit(1);
        }
        catch(IOException ioe)
        {
            ioe.printStackTrace(System.err);
           System.exit(1);
        }

    } // End method main
 
} // End class TestXYZ
 
 
My input xml file looks like:
 
<?xml version="1.0" encoding="utf-8"?>
<RESPONSE xmlns=" http://jeep.jivanet.net/mtrschema.xsd" xmlns:mtr=" http://jeep.jivanet.net/mtrschema.xsd">
<STATUS>0</STATUS>
<DOC type="OWL">
<rdf:RDF xmlns=" http://onts.dia.mil/ct.owl#" xmlns:ct=" http://onts.dia.mil/ct.owl#" xmlns:rdf=" http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs=" http://www.w3.org/2000/01/rdf-schema#">
    <rdf:Description rdf:ID="AEROmetadata">
        <rdf:type rdf:resource=" http://onts.dia.mil/ct.owl#Metadata"/ <http://onts.dia.mil/ct.owl#Metadata> >
        <sourceDateOfInfo rdf:resource="#AEROmetadatadate"/>
    </rdf:Description>
    <rdf:Description rdf:ID="AEROmetadatadate">
        <rdf:type rdf:resource=" http://onts.dia.mil/ct.owl#DateTime"/ <http://onts.dia.mil/ct.owl#DateTime> >
    </rdf:Description>
    <rdf:Description rdf:ID="SMOOSH0000000053">
        <hasMetadata rdf:resource="#AEROmetadata"/>
        <rdf:type rdf:resource=" http://onts.dia.mil/ct.owl#Person"/ <http://onts.dia.mil/ct.owl#Person> >
        <hasName>Low Graphics</hasName>
        <gender>NONE</gender>
        <hasRefs rdf:resource="#SMOOSH0000000053r"/>
    </rdf:Description>
    <rdf:Description rdf:ID="SMOOSH0000000053r">
        <hasMetadata rdf:resource="#AEROmetadata"/>
        <rdf:type rdf:resource=" http://onts.dia.mil/ct.owl#Refs"/ <http://onts.dia.mil/ct.owl#Refs> >
        <ref>105,116</ref>
    </rdf:Description>
    <rdf:Description rdf:ID="SMOOSH0000000006">
        <hasMetadata rdf:resource="#AEROmetadata"/>
        <rdf:type rdf:resource=" http://onts.dia.mil/ct.owl#CommercialOrganization"/ <http://onts.dia.mil/ct.owl#CommercialOrganization> >
        <hasName>BBC News</hasName>
        <hasRefs rdf:resource="#SMOOSH0000000006r"/>
        <hasName>BBC World Service</hasName>
        <hasName>BBC</hasName>
        <hasName>BBC WORLD SERVICE</hasName>
        <hasMetadata rdf:resource="#NetOwlmetadata" xmlns:rdf=" http://www.w3.org/1999/02/22-rdf-syntax-ns#"/ <http://www.w3.org/1999/02/22-rdf-syntax-ns#> >
    </rdf:Description>
         .
         .
         .
</rdf:RDF>
</DOC>
</RESPONSE
 
The input xml file contains 97 "hasRefs" elements like:   <hasRefs rdf:resource="#SMOOSH0000000053r"/>.
The output  file also contains 97 "hasRefs" elements, but 50 of them come out without the "rdf:" namespace alias:
 
 <hasRefs resource="#SMOOSH0000000053r"/>
 
Why would that happen?
 
Any help would be most appreciated,
 
Neil

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20040129/f548820a/attachment.htm


More information about the jdom-interest mailing list