A
Amit Jain
Hi All,
I am trying to configure catalog resolver api in my project.
But getting exception as mention below:
************************ Exception Start ***********************
org.jdom.input.JDOMParseException: Error on line 2 of document
file:///C://Workspace//catalogresolver//classes//note.xml: cvc-elt.1:
Cannot find the declaration of element 'note'.
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:465)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at TestResolver.main(TestResolver.java:41)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'note'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error
(ErrorHandlerWrapper.java:172)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:382)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:316)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:
779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1242)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
... 2 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'note'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error
(ErrorHandlerWrapper.java:172)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:382)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:316)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:
779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1242)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at TestResolver.main(TestResolver.java:41)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'note'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error
(ErrorHandlerWrapper.java:172)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:382)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:316)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:
779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1242)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at TestResolver.main(TestResolver.java:41)
************************ Exception End ***********************
************************ Java Code Start ***********************
import org.apache.xml.resolver.tools.CatalogResolver;
import org.jdom.input.SAXBuilder;
import org.jdom.Document;
public class TestResolver {
public static void main(String[] args) throws Exception{
CatalogResolver cr = new CatalogResolver();
SAXBuilder builder = new SAXBuilder();
builder.setFeature("http://apache.org/xml/features/validation/
schema", true);
builder.setFeature("http://xml.org/sax/features/namespaces",
true);
builder.setEntityResolver(cr);
String name = "http://apache.org/xml/properties/schema/
external-schemaLocation";
String value = "http://schemas.xml.org/abc/123/";
builder.setProperty(name, value);
try{
Document doc = builder.build("C://Workspace//
catalogresolver//classes//note.xml");
}catch(Exception e){
e.printStackTrace();
}
}
************************ Java Code End ***********************
************************ CatalogManager.properties Start
***********************
catalogs=corecatalog.xml;
relative-catalogs=false
static-catalog=yes
catalog-class-name=org.apache.xml.resolver.Resolver
verbosity=1
************************ CatalogManager.properties End
***********************
************************ corecatalog.xml Start
***********************
<catalog xmlns="urnasis:names:tc:entity:xmlns:xml:catalog">
<system systemId="http://schemas.xmlsoap.org/soap/envelope/"
uri="note.xsd"/>
</catalog>
************************ corecatalog.xml End
***********************
************************ note.xml Start ***********************
<?xml version="1.0"?>
<note xmlns="http://schemas.xml.org/abc/123/">
<to>Amit</to>
<from>Jain</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
************************ note.xml End ***********************
************************ note.xsd Start ***********************
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xml.org/abc/123/"
targetNamespace="http://schemas.xml.org/abc/123/">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
************************ note.xsd End ***********************
I took reference from below mentioned URL's:
- http://www.sagehill.net/docbookxsl/UseCatalog.html
- http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
If I missed something which need to be added to dig into issue. please
let me know...
Thanks in advance.
Thanks & regards,
Amit Jain
I am trying to configure catalog resolver api in my project.
But getting exception as mention below:
************************ Exception Start ***********************
org.jdom.input.JDOMParseException: Error on line 2 of document
file:///C://Workspace//catalogresolver//classes//note.xml: cvc-elt.1:
Cannot find the declaration of element 'note'.
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:465)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at TestResolver.main(TestResolver.java:41)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'note'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error
(ErrorHandlerWrapper.java:172)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:382)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:316)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:
779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1242)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
... 2 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'note'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error
(ErrorHandlerWrapper.java:172)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:382)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:316)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:
779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1242)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at TestResolver.main(TestResolver.java:41)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'note'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException
(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error
(ErrorHandlerWrapper.java:172)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:382)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:316)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1944)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:705)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:
779)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1242)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:891)
at TestResolver.main(TestResolver.java:41)
************************ Exception End ***********************
************************ Java Code Start ***********************
import org.apache.xml.resolver.tools.CatalogResolver;
import org.jdom.input.SAXBuilder;
import org.jdom.Document;
public class TestResolver {
public static void main(String[] args) throws Exception{
CatalogResolver cr = new CatalogResolver();
SAXBuilder builder = new SAXBuilder();
builder.setFeature("http://apache.org/xml/features/validation/
schema", true);
builder.setFeature("http://xml.org/sax/features/namespaces",
true);
builder.setEntityResolver(cr);
String name = "http://apache.org/xml/properties/schema/
external-schemaLocation";
String value = "http://schemas.xml.org/abc/123/";
builder.setProperty(name, value);
try{
Document doc = builder.build("C://Workspace//
catalogresolver//classes//note.xml");
}catch(Exception e){
e.printStackTrace();
}
}
************************ Java Code End ***********************
************************ CatalogManager.properties Start
***********************
catalogs=corecatalog.xml;
relative-catalogs=false
static-catalog=yes
catalog-class-name=org.apache.xml.resolver.Resolver
verbosity=1
************************ CatalogManager.properties End
***********************
************************ corecatalog.xml Start
***********************
<catalog xmlns="urnasis:names:tc:entity:xmlns:xml:catalog">
<system systemId="http://schemas.xmlsoap.org/soap/envelope/"
uri="note.xsd"/>
</catalog>
************************ corecatalog.xml End
***********************
************************ note.xml Start ***********************
<?xml version="1.0"?>
<note xmlns="http://schemas.xml.org/abc/123/">
<to>Amit</to>
<from>Jain</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
************************ note.xml End ***********************
************************ note.xsd Start ***********************
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xml.org/abc/123/"
targetNamespace="http://schemas.xml.org/abc/123/">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
************************ note.xsd End ***********************
I took reference from below mentioned URL's:
- http://www.sagehill.net/docbookxsl/UseCatalog.html
- http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
If I missed something which need to be added to dig into issue. please
let me know...
Thanks in advance.
Thanks & regards,
Amit Jain