ANT XML validation with xerces
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 8
- Joined: Tue Jan 27, 2015 2:36 pm
ANT XML validation with xerces
Hello,
I tried to validate some xml files with xerces parser launch with ANT script. My XML files have a DOCTYPE declaration to define the ENTITY graphic not to define a dtd. My XML files must be validate against a schema. See below an example :
When I execute my script I obtained :
My ANT script is :
The parser try to found a DTD in the DOCTYPE declaration. The validation with my xsd works (the last message come from the validation against my schema).
How can I tell to xerces to ignore the doctype?
Obsiously before to ask here, I searched on google but I didn't find the feature to use.
Thank for your help.
Regards
I tried to validate some xml files with xerces parser launch with ANT script. My XML files have a DOCTYPE declaration to define the ENTITY graphic not to define a dtd. My XML files must be validate against a schema. See below an example :
Code: Select all
<!DOCTYPE task [
<!ENTITY ICN-LEAP-1A-725800-B-F0301-00285-A-001-01 SYSTEM "ICN-LEAP-1A-725800-B-F0301-00285-A-001-01.cgm" NDATA cgm>
<!NOTATION cgm SYSTEM "cgm">]><task xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" chapnbr="72" sectnbr="24".....
xsi:noNamespaceSchemaLocation="http://www.snecma.com/techpub/schemas/ata/em.xsd">
<effect>......
Code: Select all
[schemavalidate] ....procedure.xml:18:88: Element type "task" must be declared.
[schemavalidate] ....procedure.xml:19:12: Element type "effect" must be declared.
[schemavalidate] ....procedure.xml:23:33: Element type "sbeff" must be declared.
[schemavalidate] ....procedure.xml:37:55: cvc-complex-type.2.4.d: Invalid content was found starting with element 'effect'. No child element is expected at this point
....
...
Code: Select all
<schemavalidate failonerror="true" lenient="no" warn="yes"
classname="org.apache.xerces.parsers.SAXParser">
<fileset dir="${outdir}" includes="*.xml"/>
<classpath location="../tools/xercesImpl.jar"/>
<attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
<attribute name="http://xml.org/sax/features/validation" value="true"/>
<xmlcatalog>
<catalogpath location="..\catalog.xml"/>
</xmlcatalog>
</schemavalidate>
How can I tell to xerces to ignore the doctype?
Obsiously before to ask here, I searched on google but I didn't find the feature to use.
Thank for your help.
Regards
-
- Posts: 9421
- Joined: Fri Jul 09, 2004 5:18 pm
Re: ANT XML validation with xerces
Hi,
I'm not sure if this can be made to work or not, never tried it myself.
Looking at the ANT documentation for the task you are using:
https://ant.apache.org/manual/Tasks/schemavalidate.html
it seems to have a disableDTD attribute but I'm not sure if it would help you or not.
Regards,
Radu
I'm not sure if this can be made to work or not, never tried it myself.
Looking at the ANT documentation for the task you are using:
https://ant.apache.org/manual/Tasks/schemavalidate.html
it seems to have a disableDTD attribute but I'm not sure if it would help you or not.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 8
- Joined: Tue Jan 27, 2015 2:36 pm
Re: ANT XML validation with xerces
Hello Radu,
It seems that it is not possible to use xerces parser to do that (see https://xerces.apache.org/xerces2-j/faq-pcfp.html#faq-4). It is strange because when I validate my xml file in Oxygen by using xerces I don't have the problem.
I found a solution who is to use the default parser implemented by ant by default (SAX2 parser implementation provided by JAXP).
I wrote this and it works:
I put the property http://java.sun.com/xml/jaxp/properties/schemaLanguage for do not report DTD validation errors.
Best regards
It seems that it is not possible to use xerces parser to do that (see https://xerces.apache.org/xerces2-j/faq-pcfp.html#faq-4). It is strange because when I validate my xml file in Oxygen by using xerces I don't have the problem.
I found a solution who is to use the default parser implemented by ant by default (SAX2 parser implementation provided by JAXP).
I wrote this and it works:
Code: Select all
<xmlvalidate failonerror="false" lenient="no" warn="yes">
<fileset dir="${outdir}" includes="*.xml"/>
<!--<classpath location="../tools/xercesImpl.jar"/> -->
<!--classname="org.apache.xerces.parsers.SAXParser"-->
<attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
<attribute name="http://xml.org/sax/features/validation" value="true"/>
<attribute name="http://xml.org/sax/features/namespaces" value="true"/>
<xmlcatalog>
<catalogpath location="..\catalog.xml"/>
</xmlcatalog>
<property name="http://java.sun.com/xml/jaxp/properties/schemaLanguage" value="http://www.w3.org/2001/XMLSchema"/>
</xmlvalidate>
Best regards
-
- Posts: 9421
- Joined: Fri Jul 09, 2004 5:18 pm
Re: ANT XML validation with xerces
Hi,
About this remark:
For example in cases in which the XML has a DTD associated we first do a detection to see if there are any element definitions in the DTD. If not, we realize the DTD is used only to store entity definitions and we force Xerces only to validate using the other detected schemas.
Regards,
Radu
About this remark:
Oxygen also uses Xerces for validation but it completely controls the Xerces parser by directly using its Java API.It is strange because when I validate my xml file in Oxygen by using xerces I don't have the problem.
For example in cases in which the XML has a DTD associated we first do a detection to see if there are any element definitions in the DTD. If not, we realize the DTD is used only to store entity definitions and we force Xerces only to validate using the other detected schemas.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service