i having problem schema validation , jdom (ver 1.1.3). didn't know how resolve issue. grateful if can me.
here stack trace of exception @ runtime, code fragment tries build document , generate exception , xml file , xsd file.
thanks.
[exception] warning: error on line 11 of document file:c:/dsol2/experiment_3.0.xml: cvc-elt.1: cannot find declaration of element 'experimentalframe'. org.jdom.input.jdomparseexception: error on line 11 of document file:c:/dsol2/experiment_3.0.xml: cvc-elt.1: cannot find declaration of element 'experimentalframe'. @ org.jdom.input.saxbuilder.build(saxbuilder.java:530) @ org.jdom.input.saxbuilder.build(saxbuilder.java:905) @ nl.tudelft.simulation.xml.dsol.experimentparser.parseexperimentalframe(experimentparser.java:130) @ nl.tudelft.simulation.xml.dsol.experimentparser.parseexperimentalframe(experimentparser.java:96) @ dsol2.consolerunner.main(consolerunner.java:64) caused by: org.xml.sax.saxparseexception; systemid: file:c:/dsol2/experiment_3.0.xml; linenumber: 11; columnnumber: 57; cvc-elt.1: cannot find declaration of element 'experimentalframe'. @ org.apache.xerces.util.errorhandlerwrapper.createsaxparseexception(unknown source) @ org.apache.xerces.util.errorhandlerwrapper.error(unknown source) @ org.apache.xerces.impl.xmlerrorreporter.reporterror(unknown source) @ org.apache.xerces.impl.xmlerrorreporter.reporterror(unknown source) @ org.apache.xerces.impl.xmlerrorreporter.reporterror(unknown source) @ org.apache.xerces.impl.xs.xmlschemavalidator.handlestartelement(unknown source) @ org.apache.xerces.impl.xs.xmlschemavalidator.startelement(unknown source) @ org.apache.xerces.impl.xmlnsdocumentscannerimpl.scanstartelement(unknown source) @ org.apache.xerces.impl.xmlnsdocumentscannerimpl$nscontentdispatcher.scanrootelementhook(unknown source) @ org.apache.xerces.impl.xmldocumentfragmentscannerimpl$fragmentcontentdispatcher.dispatch(unknown source) @ org.apache.xerces.impl.xmldocumentfragmentscannerimpl.scandocument(unknown source) @ org.apache.xerces.parsers.xml11configuration.parse(unknown source) @ org.apache.xerces.parsers.xml11configuration.parse(unknown source) @ org.apache.xerces.parsers.xmlparser.parse(unknown source) @ org.apache.xerces.parsers.abstractsaxparser.parse(unknown source) @ org.jdom.input.saxbuilder.build(saxbuilder.java:518) ... 4 more caused by: org.xml.sax.saxparseexception; systemid: file:c:/dsol2/experiment_3.0.xml; linenumber: 11; columnnumber: 57; cvc-elt.1: cannot find declaration of element 'experimentalframe'. @ org.apache.xerces.util.errorhandlerwrapper.createsaxparseexception(unknown source) @ org.apache.xerces.util.errorhandlerwrapper.error(unknown source) @ org.apache.xerces.impl.xmlerrorreporter.reporterror(unknown source) @ org.apache.xerces.impl.xmlerrorreporter.reporterror(unknown source) @ org.apache.xerces.impl.xmlerrorreporter.reporterror(unknown source) @ org.apache.xerces.impl.xs.xmlschemavalidator.handlestartelement(unknown source) @ org.apache.xerces.impl.xs.xmlschemavalidator.startelement(unknown source) @ org.apache.xerces.impl.xmlnsdocumentscannerimpl.scanstartelement(unknown source) @ org.apache.xerces.impl.xmlnsdocumentscannerimpl$nscontentdispatcher.scanrootelementhook(unknown source) @ org.apache.xerces.impl.xmldocumentfragmentscannerimpl$fragmentcontentdispatcher.dispatch(unknown source) @ org.apache.xerces.impl.xmldocumentfragmentscannerimpl.scandocument(unknown source) @ org.apache.xerces.parsers.xml11configuration.parse(unknown source) @ org.apache.xerces.parsers.xml11configuration.parse(unknown source) @ org.apache.xerces.parsers.xmlparser.parse(unknown source) @ org.apache.xerces.parsers.abstractsaxparser.parse(unknown source) @ org.jdom.input.saxbuilder.build(saxbuilder.java:518) @ org.jdom.input.saxbuilder.build(saxbuilder.java:905) @ nl.tudelft.simulation.xml.dsol.experimentparser.parseexperimentalframe(experimentparser.java:130) @ nl.tudelft.simulation.xml.dsol.experimentparser.parseexperimentalframe(experimentparser.java:96) @ dsol2.consolerunner.main(consolerunner.java:64) java.lang.nullpointerexception @ dsol2.consolerunner.main(consolerunner.java:67)
the java file
private static saxbuilder builder = new saxbuilder( "org.apache.xerces.parsers.saxparser", true); static { builder.setfeature("http://xml.org/sax/features/validation", true); builder.setfeature("http://apache.org/xml/features/validation/schema",true); string xsd = "/xsd/experiment.xsd"; builder.setproperty("http://apache.org/xml/properties/schema/external-schemalocation", "http://www.simulation.tudelft.nl" + xsd); } ... element rootelement = builder.build(input).getrootelement(); //throws error here
the xml file
<?xml version="1.0" encoding="utf-8"?> <dsol:experimentalframe xmlns:dsol="http://www.simulation.tudelft.nl" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <experiment> <model> <model-class>dsol.model</model-class> <class-path> <jar-file>dist/dsol.jar</jar-file> </class-path </model> <simulator-class>nl.tudelft.simulation.dsol.simulators.devssimulator</simulator-class> <treatment> <starttime>2015-09-01t00:00:00</starttime> <timeunit>minute</timeunit> <warmupperiod unit="minute">0</warmupperiod> <runlength unit="minute">10</runlength> <replication description="replication 0"> <stream name="default" seed="1"/> </replication> <replication description="replication 1"> <stream name="default" seed="2"/> </replication> <replication description="replication 2"> <stream name="default" seed="3"/> </replication> </treatment> </experiment> </dsol:experimentalframe>
the xsd file
<!-- ############################### root definition of experiment ######################### --> <xsd:element name="experimentalframe"> <xsd:complextype mixed="true"> <xsd:sequence> <xsd:element maxoccurs="unbounded" minoccurs="1" name="experiment" type="dsol:experiment"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:complextype name="experiment" mixed="true"> <xsd:sequence> <xsd:element maxoccurs="1" minoccurs="1" name="model" type="dsol:model"/> <xsd:element maxoccurs="1" minoccurs="0" name="simulator-class" type="xsd:string"/> <xsd:element maxoccurs="1" minoccurs="1" name="treatment" type="dsol:treatment"/> </xsd:sequence> </xsd:complextype> <!-- ######################################################################################### --> <xsd:complextype name="treatment" mixed="true"> <xsd:sequence> <xsd:element name="starttime" maxoccurs="1" minoccurs="0" type="xsd:datetime"/> <xsd:element name="timeunit" default="unit" maxoccurs="1" minoccurs="1" type="dsol:timeunit"/> <xsd:element name="warmupperiod" maxoccurs="1" minoccurs="0" type="dsol:period"/> <xsd:element name="runlength" maxoccurs="1" minoccurs="0" type="dsol:period"/> <xsd:element name="properties" maxoccurs="1" minoccurs="0" type="dsol:properties"/> <xsd:element name="replication" maxoccurs="unbounded" minoccurs="1" type="dsol:replication"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="properties"> <xsd:sequence> <xsd:element name="property" maxoccurs="unbounded" minoccurs="1" type="dsol:property"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="property"> <xsd:complexcontent> <xsd:restriction base="xsd:anytype"> <xsd:attribute name="key" type="xsd:string"/> <xsd:attribute name="value" type="xsd:string"/> </xsd:restriction> </xsd:complexcontent> </xsd:complextype> <xsd:complextype name="period"> <xsd:simplecontent> <xsd:extension base="xsd:double"> <xsd:attribute name="unit" type="dsol:timeunit" use="required"/> </xsd:extension> </xsd:simplecontent> </xsd:complextype> <xsd:complextype name="model"> <xsd:sequence> <xsd:element name="model-class" maxoccurs="1" minoccurs="1" type="xsd:string"/> <xsd:element name="class-path" maxoccurs="1" minoccurs="0" type="dsol:classpath"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="classpath"> <xsd:sequence> <xsd:element name="jar-file" maxoccurs="unbounded" minoccurs="1" type="xsd:string"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="replication"> <xsd:sequence> <xsd:element name="stream" maxoccurs="unbounded" minoccurs="1" type="dsol:stream"/> </xsd:sequence> <xsd:attribute name="description" type="xsd:string"/> </xsd:complextype> <xsd:complextype name="stream"> <xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="seed" type="xsd:positiveinteger" use="required"/> </xsd:complextype> <xsd:simpletype name="timeunit"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="millisecond"/> <xsd:enumeration value="second"/> <xsd:enumeration value="minute"/> <xsd:enumeration value="hour"/> <xsd:enumeration value="day"/> <xsd:enumeration value="week"/> <xsd:enumeration value="year"/> <xsd:enumeration value="unit"/> </xsd:restriction> </xsd:simpletype> </xsd:schema>
Comments
Post a Comment