locating schemas with catalog w/out instance schemaLocations
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 5
- Joined: Thu Jul 28, 2005 5:46 pm
- Contact:
locating schemas with catalog w/out instance schemaLocations
Is the following scenario possible with oXygen? (I'm using the Eclipse version.)
1. I have a schema that starts like:
2. I have an instance document that starts like:
3. I have a catalog that starts like:
4. oXygen sees the namespace declaration in the instance document, looks in the catalog and finds out the location of the local copy of the schema for that namespace, and uses it to validate the instance document.
Note that I do not have the xsi:schemaLocation attributes in the instance document. I strongly prefer to omit those, and have validation triggered in the way I have described.
If this is not possible with oXygen out of the box, would it be possible for me to make oXygen use a different parser implementation that would be able to do this? Norm Walsh has a new version of the xml resolver code in the works, and I've been able to get it to work in this fashion. The only additional requirement is to "decorate" the catalog like this:
I like that a lot better than having to pollute my instance documents with all that xsi:schemaLocation stuff that is just intended to "fake out" the parser.
Would oXygen pay attention to the settings of these properties:
? If so, it might be possible to swap in the new xml resolver stuff and get this kind of validation to work. Or is there a simpler way to accomplish this without such tweaking?
Thanks!
1. I have a schema that starts like:
Code: Select all
<xs:schema xmlns="http://my.tld/something" targetNamespace="http://my.tld/something" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0" xml:lang="EN">
Code: Select all
<something xmlns="http://my.tld/something">
Code: Select all
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<uri name="http://my.tld/something" uri="schemas/something.xsd"/>
Note that I do not have the xsi:schemaLocation attributes in the instance document. I strongly prefer to omit those, and have validation triggered in the way I have described.
If this is not possible with oXygen out of the box, would it be possible for me to make oXygen use a different parser implementation that would be able to do this? Norm Walsh has a new version of the xml resolver code in the works, and I've been able to get it to work in this fashion. The only additional requirement is to "decorate" the catalog like this:
Code: Select all
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:r="http://www.rddl.org/" prefer="system">
<uri r:nature="http://www.w3.org/2001/XMLSchema"
r:purpose="http://www.rddl.org/purposes#schema-validation" name="http://my.tld/something" uri="schemas/something.xsd"/>
Would oXygen pay attention to the settings of these properties:
Code: Select all
javax.xml.parsers.SAXParserFactory
javax.xml.stream.XMLInputFactory
javax.xml.parsers.DocumentBuilderFactory
Thanks!
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
What you can do currently in oXygen to get a schema associated with a document without specifying that association in the document is to use the Defautl Schema Association options, see in Eclipse Window->Preferences -- oXygen -- Editor -- Default Schema Association page. There you can specify based on the root element local name and namespace and/or based on the file name a schema file to be used for validation and content completion on the documents that match.
oXygen uses the Xerces J parser at SAX level and SAX cannot distinguish between a schema, a DTD or external entities when it invokes a resolver. Therefore it is not possible to use the URI catalog entries to resolve a schema based only on its namespace. In the future there are plans to allow for that possibility - however as explained above most of this use case is covered by the default schema association options.
Best Regards,
George
What you can do currently in oXygen to get a schema associated with a document without specifying that association in the document is to use the Defautl Schema Association options, see in Eclipse Window->Preferences -- oXygen -- Editor -- Default Schema Association page. There you can specify based on the root element local name and namespace and/or based on the file name a schema file to be used for validation and content completion on the documents that match.
oXygen uses the Xerces J parser at SAX level and SAX cannot distinguish between a schema, a DTD or external entities when it invokes a resolver. Therefore it is not possible to use the URI catalog entries to resolve a schema based only on its namespace. In the future there are plans to allow for that possibility - however as explained above most of this use case is covered by the default schema association options.
Best Regards,
George
George Cristian Bina
-
- Posts: 1
- Joined: Fri Oct 08, 2010 6:14 pm
Re: locating schemas with catalog w/out instance schemaLocations
Hi,
I have the same problem (I don't want any ugly schemaLocation attributes in my XML documents). To avoid the schemaLocation attribute, I also tried an XML catalog (with URI mappings).
It works partially, but I found an inconsistent resolving behaviour which I think is not correct. (before I continue: I am using Oxygen version 12.0., therefore I could not follow your hint with the default schema association preferences, I could not find this preference in Version 12.0).
I have two little schemas, schema_a.xsd, schema_b.xsd.
schema_a.xsd
schema_b.xsd
The XML catalog:
The instance file:
Strangely enough, the schema_a.xsd got resolved by the catalog mapping, where schema_b.xsd didn't get resolved. I get the error:
When using the Eclipse XML Editor and the Eclipse XML catalog resolver (WTP plugin), the above example works as it should.
Is there anything I can do to get this configuration working with Oxygen, too? I want to make the switch from Eclipse to Oxygen, but this hurdle is really startling me.
Thanks for your help,
Regards,
Martin
I have the same problem (I don't want any ugly schemaLocation attributes in my XML documents). To avoid the schemaLocation attribute, I also tried an XML catalog (with URI mappings).
It works partially, but I found an inconsistent resolving behaviour which I think is not correct. (before I continue: I am using Oxygen version 12.0., therefore I could not follow your hint with the default schema association preferences, I could not find this preference in Version 12.0).
I have two little schemas, schema_a.xsd, schema_b.xsd.
schema_a.xsd
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
elementFormDefault="qualified"
targetNamespace="http://a" xmlns="http://a"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="test" type="xsd:boolean"/>
<xsd:any maxOccurs="unbounded" minOccurs="0" namespace="##any" processContents="strict"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
elementFormDefault="qualified"
targetNamespace="http://b" xmlns="http://b"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="number" type="xsd:integer"/>
</xsd:schema>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri name="http://a" uri="file:/C:/test/schema_a.xsd"/>
<uri name="http://b" uri="file:/C:/test/schema_b.xsd"/>
</catalog>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<a:root xmlns:a="http://a" xmlns:b="http://b">
<a:test>true</a:test>
<b:number>1</b:number>
</a:root>
(Of course I also tried using an explicit schemaLocation, if I do so, everything validates as it should)."cvc-complex-type.2.4.c: The matching wildcard is strict,
but no declaration can be found for element 'b:number'.
When using the Eclipse XML Editor and the Eclipse XML catalog resolver (WTP plugin), the above example works as it should.
Is there anything I can do to get this configuration working with Oxygen, too? I want to make the switch from Eclipse to Oxygen, but this hurdle is really startling me.
Thanks for your help,
Regards,
Martin
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: locating schemas with catalog w/out instance schemaLocations
To make this work you need to add in schema_a.xsd
<xsd:import namespace="http://b"/>
and make sure you enable the
"Process namespaces through uri mappings for XML Schema" in Options->Preferences -- XML / XML Catalog in oXygen standalone. In Eclipse the location is Eclipse->Preferences -- oXygen -- XML -- XML Catalog.
Best Regards,
George
<xsd:import namespace="http://b"/>
and make sure you enable the
"Process namespaces through uri mappings for XML Schema" in Options->Preferences -- XML / XML Catalog in oXygen standalone. In Eclipse the location is Eclipse->Preferences -- oXygen -- XML -- XML Catalog.
Best Regards,
George
George Cristian Bina
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