<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>I have the following
program that reads in an xml file, builds a Jdom tree and writes it out using
XMLOutputter:</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial color=#0000ff>import
java.util.*;<BR>import java.io.*;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial color=#0000ff>import
org.jdom.*;<BR>import org.jdom.input.DOMBuilder;<BR>import
org.jdom.input.SAXBuilder;<BR>import org.jdom.output.DOMOutputter;<BR>import
org.jdom.output.XMLOutputter;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial color=#0000ff>class
TestXYZ<BR>{<BR> TestXYZ<BR>
{<BR> }</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial
color=#0000ff> public static void main( String[] args
)<BR> {</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial
color=#0000ff> String
fileName = null;<BR></FONT></SPAN><FONT
face=Arial></FONT></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial
color=#0000ff> fileName =
args[0];</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial
color=#0000ff> try<BR> {<BR>
SAXBuilder saxBuilder = new
SAXBuilder();<BR>
Document jdomDocument1 = saxBuilder.build( fileName );</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial
color=#0000ff>
XMLOutputter outp = new
XMLOutputter();<BR>
outp.setTextTrim(true);<BR>
outp.setIndent("
");<BR>
outp.setNewlines(true);<BR>
outp.output( jdomDocument1, new BufferedOutputStream(new FileOutputStream(
fileName + "FromJdom.xml" )) );</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial
color=#0000ff> }<BR>
catch(JDOMException jde)<BR>
{<BR>
jde.printStackTrace(System.err);<BR>
System.exit(1);<BR> }<BR>
catch(IOException ioe)<BR>
{<BR>
ioe.printStackTrace(System.err);<BR>
System.exit(1);<BR>
}</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial><BR><FONT
color=#0000ff> } // End method main</FONT></FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial color=#0000ff>} // End
class TestXYZ</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>My input xml file looks
like:</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial><?xml version="1.0"
encoding="utf-8"?><BR><RESPONSE xmlns="<A
href="http://jeep.jivanet.net/mtrschema.xsd">http://jeep.jivanet.net/mtrschema.xsd</A>"
xmlns:mtr="<A
href="http://jeep.jivanet.net/mtrschema.xsd">http://jeep.jivanet.net/mtrschema.xsd</A>"><BR><STATUS>0</STATUS><BR><DOC
type="OWL"><BR><rdf:RDF xmlns="<A
href="http://onts.dia.mil/ct.owl">http://onts.dia.mil/ct.owl</A>#" xmlns:ct="<A
href="http://onts.dia.mil/ct.owl">http://onts.dia.mil/ct.owl</A>#" xmlns:rdf="<A
href="http://www.w3.org/1999/02/22-rdf-syntax-ns">http://www.w3.org/1999/02/22-rdf-syntax-ns</A>#"
xmlns:rdfs="<A
href="http://www.w3.org/2000/01/rdf-schema">http://www.w3.org/2000/01/rdf-schema</A>#"><BR>
<rdf:Description
rdf:ID="AEROmetadata"><BR>
<rdf:type rdf:resource="<A
href='http://onts.dia.mil/ct.owl#Metadata"/'>http://onts.dia.mil/ct.owl#Metadata"/</A>><BR>
<sourceDateOfInfo rdf:resource="#AEROmetadatadate"/><BR>
</rdf:Description><BR> <rdf:Description
rdf:ID="AEROmetadatadate"><BR>
<rdf:type rdf:resource="<A
href='http://onts.dia.mil/ct.owl#DateTime"/'>http://onts.dia.mil/ct.owl#DateTime"/</A>><BR>
</rdf:Description><BR> <rdf:Description
rdf:ID="SMOOSH0000000053"><BR>
<hasMetadata
rdf:resource="#AEROmetadata"/><BR>
<rdf:type rdf:resource="<A
href='http://onts.dia.mil/ct.owl#Person"/'>http://onts.dia.mil/ct.owl#Person"/</A>><BR>
<hasName>Low
Graphics</hasName><BR>
<gender>NONE</gender><BR>
<hasRefs rdf:resource="#SMOOSH0000000053r"/><BR>
</rdf:Description><BR> <rdf:Description
rdf:ID="SMOOSH0000000053r"><BR>
<hasMetadata
rdf:resource="#AEROmetadata"/><BR>
<rdf:type rdf:resource="<A
href='http://onts.dia.mil/ct.owl#Refs"/'>http://onts.dia.mil/ct.owl#Refs"/</A>><BR>
<ref>105,116</ref><BR>
</rdf:Description><BR> <rdf:Description
rdf:ID="SMOOSH0000000006"><BR>
<hasMetadata
rdf:resource="#AEROmetadata"/><BR>
<rdf:type rdf:resource="<A
href='http://onts.dia.mil/ct.owl#CommercialOrganization"/'>http://onts.dia.mil/ct.owl#CommercialOrganization"/</A>><BR>
<hasName>BBC
News</hasName><BR> <hasRefs
rdf:resource="#SMOOSH0000000006r"/><BR>
<hasName>BBC World
Service</hasName><BR>
<hasName>BBC</hasName><BR>
<hasName>BBC WORLD
SERVICE</hasName><BR>
<hasMetadata rdf:resource="#NetOwlmetadata" xmlns:rdf="<A
href='http://www.w3.org/1999/02/22-rdf-syntax-ns#"/'>http://www.w3.org/1999/02/22-rdf-syntax-ns#"/</A>><BR>
</rdf:Description></FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT
face=Arial>
.</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT
face=Arial>
.</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT
face=Arial>
.<BR></rdf:RDF><BR></DOC><BR></RESPONSE</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>The input xml file contains
97 "hasRefs" elements like: <hasRefs
rdf:resource="#SMOOSH0000000053r"/>.<BR>The output file also contains
97 "hasRefs" elements, but 50 of them come out without the "rdf:" namespace
alias:</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial> <hasRefs
resource="#SMOOSH0000000053r"/></FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>Why would that
happen?</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>Any help would be most
appreciated,</FONT></SPAN></DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=652334123-29012004><FONT face=Arial>Neil</DIV>
<DIV><BR></DIV></FONT></SPAN>
<DIV><FONT face=Arial></FONT> </DIV></BODY></HTML>