Hello All,
I am using Castor 0.9.5.
I have this code:
/**
*Method used to test the full package.
*FacilitySiteList is the main element, and this is the main method
for that class.
*The xml file I'm using was create with the same schema that created
this class package in Castor.
*The xml file was created using XML Spy 5.0 Enterprise.
*/
public static void main(String args[])
{
try
{
//we need to check the first parameter to see if it is a file.
java.io.File param1 = new java.io.File(args[0]);
if( !param1.isFile() )
{
throw new Exception("The input isn't a File.");
}
if(args.length < 2 )
{
printUsage();
return;
}
if(args[1].length() < 2)
{
throw new Exception("The output would not be a valid
file.");
}//end if
//now we need to setup our reader and writer.
java.io.FileWriter out = new java.io.FileWriter(args[1]);
java.io.FileReader in = new java.io.FileReader(param1);
System.out.println("Unmarshalling: " +
param1.getCanonicalPath());
FacilitySiteList fsl = FacilitySiteList.unmarshal(in);
System.out.println("Marshalling: " + args[0] + " to " +
args[1]);
fsl.marshal(out);
}
catch(Exception e)
{
printUsage();
System.out.println(e.toString());
e.printStackTrace();
}
}//end main
It is producing this error:
Unmarshalling:
C:\projects\Redesetgrow\SCDHEC\Node\src\net\scdhec\node\castor\frs22\xml
\frs22_test_data.xml
Usage: java FacilitySiteList <input file> <output file>
java.lang.NullPointerException
java.lang.NullPointerException
at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.jav
a:1090)
at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(U
nknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDis
patcher.dispatch(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unkno
wn Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:487)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:627)
at
net.scdhec.node.castor.frs22.FacilitySiteList.unmarshal(FacilitySiteList
.java:96)
at
net.scdhec.node.castor.frs22.FacilitySiteList.main(FacilitySiteList.java
:139)
The file I'm inputting was produced with the schema from XML Spy. I
can't figure out why castor is getting an error. I have validated the
xml inside of Netbeans 3.5 using Xerces. It validated fine. I also
checked the the xml inside of Netbeans. It seemed to be able to parse
the file fine. I can send the schema's (there are many included schema)
and the xml file if anyone is willing to help with that.
Any help is greatly appreciated.
Thank you,
Wade Chandler
[EMAIL PROTECTED]
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev