You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Simon Bøggild <si...@gmail.com> on 2007/12/02 20:06:23 UTC

Use of XMLCatalogResolver

Hi,

I'm trying to use XMLCatalogResolver as the ResourceResolver for a
SchemaFactory when validating schemas. I've created a catalog file
following the http://www.oasis-open.org/committees/entity/spec-2001-08-06.html.
In the schemas that I check I have references to external schemas on
the Internet, which is why I'm interested in keeping a local copy of
those, and use a xml catalog to make the re-references when parsing
schemas with SchemaFactory. It goes well for most of the referenced
schemas, except when it comes to a particular schema:
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd.
For some reason the local copy I'm re-referencing to is not enough to
make the schema validate. I'm getting the following error when
SchemaFactory tries to parse it:

org.xml.sax.SAXParseException: schema_reference.4: Failed to read
schema document 'file:/path/to/xmldsig-core/xmldsig-core-schema.xsd',
because 1) could not find the document; 2) the document could not be
read; 3) the root element of the document is not <xsd:schema>.

The schema is imported the following way from one of the schemas I use:

<import namespace="http://www.w3.org/2000/09/xmldsig#"
            schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"/>

I'm suspecting the problem might have something to do with the
namespace, which contains the '#' symbol? The xmldsig-core-schema does
not import any schemas itself.

I've tried using a rewrite like this:
<rewriteSystem systemIdStartString="http://www.w3.org/TR/xmldsig-core/"
rewritePrefix="file:///path/to/xmldsig-core/"/>

and I've also tried a systemId:
<system systemId="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
uri="/path/to/xmldsig-core/xmldsig-core-schema.xsd"/>

No matter how I seem to make the catalog I get the SAXParseException
when SchemaFactory tries to parse the local xmldsig-core.schema file.
All schemas are validated without any problems without the catalog.

How is it possible to correct the catalog to solve the problem?

Thanks,
Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


RE: XSAttributeGroupDefinition

Posted by Srdjan Djuricic <sd...@galdosinc.com>.
Thank you Michael. 


 Be there when the Web and GIS unite! Register now for GeoWeb 2007 at
www.geoweb.org 
-----Original Message-----
From: Michael Glavassevich [mailto:mrglavas@ca.ibm.com] 
Sent: Friday, December 07, 2007 8:17 AM
To: j-users@xerces.apache.org
Subject: Re: XSAttributeGroupDefinition

Stanimir Stamenkov <s7...@netscape.net> wrote on 12/07/2007 01:34:08
AM:

> Thu, 6 Dec 2007 10:38:59 -0800, /Srdjan Djuricic/:
>
> > My issue is when parsing a
> > XSAttributeGroupDefinition and encountering a XSAttributeUse I don't

> > know how to identify whether that attributeUse is obtained from 
> > another

> > attributeGroup or not.
>
> As far as I can tell you can't determine what you want using the 
> Xerces XSModel API, but I don't think it is designed to parse an XML 
> Schema in such detail.  It implements the abstract model defined in 
> the XML Schema Structures specification and is primarily intended for 
> use of validation, i.e. it is read-only and light-weight.

Right, there's no representation of a reference to an attribute group
definition in the model. The {attribute uses} contained in them get
absorbed into the complex type definition's {attribute uses}. The spec
describes how that's computed here:
http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/#declare-type. See
the definition of {attribute uses) in the sections titled "Complex Type
Definition ... Schema Component".

> I think you need another API like the Eclipse XSD model [1] to analyze

> (and possibly modify) the source XML Schema document(s) in greater 
> detail.
>
> [1] http://www.eclipse.org/modeling/mdt/?project=xsd
>
> --
> Stanimir
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


RE: XSAttributeGroupDefinition

Posted by Srdjan Djuricic <sd...@galdosinc.com>.
Thank you Stanimir,

I will check out the API that you recommended. 


 Be there when the Web and GIS unite! Register now for GeoWeb 2007 at
www.geoweb.org 
-----Original Message-----
From: Stanimir Stamenkov [mailto:s7an10@netscape.net] 
Sent: Thursday, December 06, 2007 10:34 PM
To: j-users@xerces.apache.org
Subject: Re: XSAttributeGroupDefinition

Thu, 6 Dec 2007 10:38:59 -0800, /Srdjan Djuricic/:

> My issue is when parsing a
> XSAttributeGroupDefinition and encountering a XSAttributeUse I don't 
> know how to identify whether that attributeUse is obtained from 
> another attributeGroup or not.

As far as I can tell you can't determine what you want using the Xerces
XSModel API, but I don't think it is designed to parse an XML Schema in
such detail.  It implements the abstract model defined in the XML Schema
Structures specification and is primarily intended for use of
validation, i.e. it is read-only and light-weight.  I think you need
another API like the Eclipse XSD model [1] to analyze (and possibly
modify) the source XML Schema document(s) in greater detail.

[1] http://www.eclipse.org/modeling/mdt/?project=xsd

--
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XSAttributeGroupDefinition

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Stanimir Stamenkov <s7...@netscape.net> wrote on 12/07/2007 01:34:08 AM:

> Thu, 6 Dec 2007 10:38:59 -0800, /Srdjan Djuricic/:
>
> > My issue is when parsing a
> > XSAttributeGroupDefinition and encountering a XSAttributeUse I don't
> > know how to identify whether that attributeUse is obtained from another

> > attributeGroup or not.
>
> As far as I can tell you can't determine what you want using the
> Xerces XSModel API, but I don't think it is designed to parse an XML
> Schema in such detail.  It implements the abstract model defined in
> the XML Schema Structures specification and is primarily intended
> for use of validation, i.e. it is read-only and light-weight.

Right, there's no representation of a reference to an attribute group
definition in the model. The {attribute uses} contained in them get
absorbed into the complex type definition's {attribute uses}. The spec
describes how that's computed here:
http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/#declare-type. See the
definition of {attribute uses) in the sections titled "Complex Type
Definition ... Schema Component".

> I think you need another API like the Eclipse XSD model [1] to analyze
> (and possibly modify) the source XML Schema document(s) in greater
> detail.
>
> [1] http://www.eclipse.org/modeling/mdt/?project=xsd
>
> --
> Stanimir
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XSAttributeGroupDefinition

Posted by Stanimir Stamenkov <s7...@netscape.net>.
Thu, 6 Dec 2007 10:38:59 -0800, /Srdjan Djuricic/:

> My issue is when parsing a 
> XSAttributeGroupDefinition and encountering a XSAttributeUse I don't 
> know how to identify whether that attributeUse is obtained from another 
> attributeGroup or not.

As far as I can tell you can't determine what you want using the 
Xerces XSModel API, but I don't think it is designed to parse an XML 
Schema in such detail.  It implements the abstract model defined in 
the XML Schema Structures specification and is primarily intended 
for use of validation, i.e. it is read-only and light-weight.  I 
think you need another API like the Eclipse XSD model [1] to analyze 
(and possibly modify) the source XML Schema document(s) in greater 
detail.

[1] http://www.eclipse.org/modeling/mdt/?project=xsd

-- 
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


XSAttributeGroupDefinition

Posted by Srdjan Djuricic <sd...@galdosinc.com>.
Hello,

	<xsd:attribute name="role" type="xsd:string"/>
	<xsd:attribute name="title" type="xsd:string"/>
	<xsd:element name="price" type="xsd:string"/>
	<xsd:attributeGroup name="secondGroup">
		<xsd:attribute name="name" type="xsd:string"
fixed="extended" form="qualified"/>
	</xsd:attributeGroup>
	<xsd:attributeGroup name="firstGroup">
		<xsd:attribute name="type" type="xsd:string"
fixed="extended" form="qualified"/>
		<xsd:attributeGroup ref="test:secondGroup"/>
		<xsd:attribute ref="test:title" use="optional"/>
	</xsd:attributeGroup>

Supppose I have the following schema above and I am using XML Schema
API.  I am parsing attribute groups and I want to find out all
XSAttributeUse that an XSAttributeGroupDefinition contains.  I don't
have an issue of finding all XSAttributeUses for
XSAttributeGroupDefinition.  My issue is when parsing a
XSAttributeGroupDefinition and encountering a XSAttributeUse I don't
know how to identify whether that attributeUse is obtained from another
attributeGroup or not.

For example:
When I parse secondGroup I get a singe attribute name.

When I parse firstGroup I get three XSAttributeUses: type, name and
title.  What I would like to somehow figure out is that attributeGroup
(firstGroup) contains another attributeGroup (secondGroup ) and that
XSAttributeUse with the name set to name is actually an attribute
defined by the first attributeGroup.  

I haven't been able to determine that at all.  By using XML Schema API
all I able to figure out is that firstGroup contains three attributes.
So the following schema

	<xsd:attributeGroup name="firstGroup">
		<xsd:attribute name="type" type="xsd:string"
fixed="extended" form="qualified"/>
		<xsd:attributeGroup ref="test:secondGroup"/>
		<xsd:attribute ref="test:title" use="optional"/>
	</xsd:attributeGroup>

Is identical to this schema

	<xsd:attributeGroup name="firstGroup">
		<xsd:attribute name="type" type="xsd:string"
fixed="extended" form="qualified"/>
		<xsd:attribute name="name" type="xsd:string"
fixed="extended" form="qualified"/>
		<xsd:attribute ref="test:title" use="optional"/>
	</xsd:attributeGroup>

Thank you,

Srdjan




---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Use of XMLCatalogResolver

Posted by Simon Bøggild <si...@gmail.com>.
Well the problem seems to be solved now, I needed a local copy of
datatypes.dtd as well, now I'm able to do the schema validation using
the xml catalog.
I used a standard implementation of LSResourceResolver and had it
print out the system Id's that it was resolving when checking the
xmldsig-core-schema.xsd file, and that's when I noticed that
datatypes.dtd was necessary.

Thanks,
Simon

On Dec 3, 2007 8:32 PM, Simon Bøggild <si...@gmail.com> wrote:
> Hi Michael,
>
> The problem seems to be this initial declaration in the xmldsig-core-schema.xsd:
>
> <!DOCTYPE schema
>   PUBLIC "-//W3C//DTD XMLSchema 200102//EN"
> "http://www.w3.org/2001/XMLSchema.dtd"
>  [
>    <!ATTLIST schema
>      xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
>    <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
>    <!ENTITY % p ''>
>    <!ENTITY % s ''>
>   ]>
>
> If I remove that section from the xsd file, then there's no problem
> using the catalog with the SchemaFactory. If the declaration is there
> I get the error message mentioned previously. XMLSchema.dtd is
> referenced in that declaration.
> I've tried to solve the problem by writing this in the xml catalog:
>
> <public publicId = "-//W3C//DTD XMLSchema 200102//EN"
> uri="/path/to/XMLSchema.dtd"/>
> , keeping a local copy of XMLSchema.dtd.
>
> I've also tried putting:
>
> <public publicId="http://www.w3.org/2000/09/xmldsig#"
> uri="/path/to/xmldsig-core-schema.xsd"/>
>
> No luck with any of those.
> So status is that cutting out the DOCTYPE declaration from the
> xmldsig-core-schema makes it possible to validate all schemas locally
> with the catalog, otherwise not.
>
> Regarding your question if I tried opening an InputStream with
> java.net.URL I'm not sure what you want me to accomplish? In short, a
> schema I have makes use of elements from xmldsig-core-schema, and I
> would simply like to be able to do my schema validation with a local
> copy of this schema rather than having Xerces SchemaValidator be
> dependant on establishing a connection to:
> http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd (I think I
> gave an incorrect address to this schema in my previous mail)
>
> Thanks,
> Simon
>
>
> On Dec 3, 2007 2:19 AM, Michael Glavassevich <mr...@ca.ibm.com> wrote:
> > Hi Simon,
> >
> > "file:/path/to/xmldsig-core/xmldsig-core-schema.xsd" seems like the correct
> > result for the "rewriteSystem" you wrote. What are you expecting to get as
> > the resolved URI from the catalog resolver? Have you tried opening an
> > InputStream for this URI yourself with java.net.URL?
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > "Simon Bøggild" <si...@gmail.com> wrote on 12/02/2007 02:06:23 PM:
> >
> >
> > > Hi,
> > >
> > > I'm trying to use XMLCatalogResolver as the ResourceResolver for a
> > > SchemaFactory when validating schemas. I've created a catalog file
> > > following the
> > http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
> > > .
> > > In the schemas that I check I have references to external schemas on
> > > the Internet, which is why I'm interested in keeping a local copy of
> > > those, and use a xml catalog to make the re-references when parsing
> > > schemas with SchemaFactory. It goes well for most of the referenced
> > > schemas, except when it comes to a particular schema:
> > >
> > http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
> > .
> > > For some reason the local copy I'm re-referencing to is not enough to
> > > make the schema validate. I'm getting the following error when
> > > SchemaFactory tries to parse it:
> > >
> > > org.xml.sax.SAXParseException: schema_reference.4: Failed to read
> > > schema document 'file:/path/to/xmldsig-core/xmldsig-core-schema.xsd',
> > > because 1) could not find the document; 2) the document could not be
> > > read; 3) the root element of the document is not <xsd:schema>.
> > >
> > > The schema is imported the following way from one of the schemas I use:
> > >
> > > <import namespace="http://www.w3.org/2000/09/xmldsig#"
> > >             schemaLocation="http://www.w3.org/TR/xmldsig-
> > > core/xmldsig-core-schema.xsd"/>
> > >
> > > I'm suspecting the problem might have something to do with the
> > > namespace, which contains the '#' symbol? The xmldsig-core-schema does
> > > not import any schemas itself.
> > >
> > > I've tried using a rewrite like this:
> > > <rewriteSystem systemIdStartString="http://www.w3.org/TR/xmldsig-core/"
> > > rewritePrefix="file:///path/to/xmldsig-core/"/>
> > >
> > > and I've also tried a systemId:
> > > <system systemId="
> > http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
> > > uri="/path/to/xmldsig-core/xmldsig-core-schema.xsd"/>
> > >
> > > No matter how I seem to make the catalog I get the SAXParseException
> > > when SchemaFactory tries to parse the local xmldsig-core.schema file.
> > > All schemas are validated without any problems without the catalog.
> > >
> > > How is it possible to correct the catalog to solve the problem?
> > >
> > > Thanks,
> > > Simon
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Use of XMLCatalogResolver

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Simon,

"Simon Bøggild" <si...@gmail.com> wrote on 12/03/2007 02:32:28 PM:

> Hi Michael,
>
> The problem seems to be this initial declaration in the xmldsig-
> core-schema.xsd:
>
> <!DOCTYPE schema
>   PUBLIC "-//W3C//DTD XMLSchema 200102//EN"
> "http://www.w3.org/2001/XMLSchema.dtd"
>  [
>    <!ATTLIST schema
>      xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
>    <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
>    <!ENTITY % p ''>
>    <!ENTITY % s ''>
>   ]>

One of these days we really should improve the reporting of that. I think
we're just trapping every IOException and reporting that generic and not
particularly very helpful error message in its place.

> If I remove that section from the xsd file, then there's no problem
> using the catalog with the SchemaFactory. If the declaration is there
> I get the error message mentioned previously. XMLSchema.dtd is
> referenced in that declaration.
> I've tried to solve the problem by writing this in the xml catalog:
>
> <public publicId = "-//W3C//DTD XMLSchema 200102//EN"
> uri="/path/to/XMLSchema.dtd"/>
> , keeping a local copy of XMLSchema.dtd.
>
> I've also tried putting:
>
> <public publicId="http://www.w3.org/2000/09/xmldsig#"
> uri="/path/to/xmldsig-core-schema.xsd"/>
>
> No luck with any of those.
> So status is that cutting out the DOCTYPE declaration from the
> xmldsig-core-schema makes it possible to validate all schemas locally
> with the catalog, otherwise not.
>
> Regarding your question if I tried opening an InputStream with
> java.net.URL I'm not sure what you want me to accomplish?

It was to confirm that you could actually read the document from the
location you specified. It was just a sanity check. Sometimes folks have a
typo in their URI or forgot to copy the document to the location. Of course
now we know that wasn't the problem here.

> In short, a
> schema I have makes use of elements from xmldsig-core-schema, and I
> would simply like to be able to do my schema validation with a local
> copy of this schema rather than having Xerces SchemaValidator be
> dependant on establishing a connection to:
> http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd (I think I
> gave an incorrect address to this schema in my previous mail)
>
> Thanks,
> Simon
>
> On Dec 3, 2007 2:19 AM, Michael Glavassevich <mr...@ca.ibm.com> wrote:
> > Hi Simon,
> >
> > "file:/path/to/xmldsig-core/xmldsig-core-schema.xsd" seems like the
correct
> > result for the "rewriteSystem" you wrote. What are you expecting to get
as
> > the resolved URI from the catalog resolver? Have you tried opening an
> > InputStream for this URI yourself with java.net.URL?
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > "Simon Bøggild" <si...@gmail.com> wrote on 12/02/2007 02:06:23
PM:
> >
> >
> > > Hi,
> > >
> > > I'm trying to use XMLCatalogResolver as the ResourceResolver for a
> > > SchemaFactory when validating schemas. I've created a catalog file
> > > following the
> > http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
> > > .
> > > In the schemas that I check I have references to external schemas on
> > > the Internet, which is why I'm interested in keeping a local copy of
> > > those, and use a xml catalog to make the re-references when parsing
> > > schemas with SchemaFactory. It goes well for most of the referenced
> > > schemas, except when it comes to a particular schema:
> > >
> >
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
> > .
> > > For some reason the local copy I'm re-referencing to is not enough to
> > > make the schema validate. I'm getting the following error when
> > > SchemaFactory tries to parse it:
> > >
> > > org.xml.sax.SAXParseException: schema_reference.4: Failed to read
> > > schema document 'file:/path/to/xmldsig-core/xmldsig-core-schema.xsd',
> > > because 1) could not find the document; 2) the document could not be
> > > read; 3) the root element of the document is not <xsd:schema>.
> > >
> > > The schema is imported the following way from one of the schemas I
use:
> > >
> > > <import namespace="http://www.w3.org/2000/09/xmldsig#"
> > >             schemaLocation="http://www.w3.org/TR/xmldsig-
> > > core/xmldsig-core-schema.xsd"/>
> > >
> > > I'm suspecting the problem might have something to do with the
> > > namespace, which contains the '#' symbol? The xmldsig-core-schema
does
> > > not import any schemas itself.
> > >
> > > I've tried using a rewrite like this:
> > > <rewriteSystem
systemIdStartString="http://www.w3.org/TR/xmldsig-core/"
> > > rewritePrefix="file:///path/to/xmldsig-core/"/>
> > >
> > > and I've also tried a systemId:
> > > <system systemId="
> > http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
> > > uri="/path/to/xmldsig-core/xmldsig-core-schema.xsd"/>
> > >
> > > No matter how I seem to make the catalog I get the SAXParseException
> > > when SchemaFactory tries to parse the local xmldsig-core.schema file.
> > > All schemas are validated without any problems without the catalog.
> > >
> > > How is it possible to correct the catalog to solve the problem?
> > >
> > > Thanks,
> > > Simon
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Use of XMLCatalogResolver

Posted by Simon Bøggild <si...@gmail.com>.
Hi Michael,

The problem seems to be this initial declaration in the xmldsig-core-schema.xsd:

<!DOCTYPE schema
  PUBLIC "-//W3C//DTD XMLSchema 200102//EN"
"http://www.w3.org/2001/XMLSchema.dtd"
 [
   <!ATTLIST schema
     xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
   <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
   <!ENTITY % p ''>
   <!ENTITY % s ''>
  ]>

If I remove that section from the xsd file, then there's no problem
using the catalog with the SchemaFactory. If the declaration is there
I get the error message mentioned previously. XMLSchema.dtd is
referenced in that declaration.
I've tried to solve the problem by writing this in the xml catalog:

<public publicId = "-//W3C//DTD XMLSchema 200102//EN"
uri="/path/to/XMLSchema.dtd"/>
, keeping a local copy of XMLSchema.dtd.

I've also tried putting:

<public publicId="http://www.w3.org/2000/09/xmldsig#"
uri="/path/to/xmldsig-core-schema.xsd"/>

No luck with any of those.
So status is that cutting out the DOCTYPE declaration from the
xmldsig-core-schema makes it possible to validate all schemas locally
with the catalog, otherwise not.

Regarding your question if I tried opening an InputStream with
java.net.URL I'm not sure what you want me to accomplish? In short, a
schema I have makes use of elements from xmldsig-core-schema, and I
would simply like to be able to do my schema validation with a local
copy of this schema rather than having Xerces SchemaValidator be
dependant on establishing a connection to:
http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd (I think I
gave an incorrect address to this schema in my previous mail)

Thanks,
Simon

On Dec 3, 2007 2:19 AM, Michael Glavassevich <mr...@ca.ibm.com> wrote:
> Hi Simon,
>
> "file:/path/to/xmldsig-core/xmldsig-core-schema.xsd" seems like the correct
> result for the "rewriteSystem" you wrote. What are you expecting to get as
> the resolved URI from the catalog resolver? Have you tried opening an
> InputStream for this URI yourself with java.net.URL?
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> "Simon Bøggild" <si...@gmail.com> wrote on 12/02/2007 02:06:23 PM:
>
>
> > Hi,
> >
> > I'm trying to use XMLCatalogResolver as the ResourceResolver for a
> > SchemaFactory when validating schemas. I've created a catalog file
> > following the
> http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
> > .
> > In the schemas that I check I have references to external schemas on
> > the Internet, which is why I'm interested in keeping a local copy of
> > those, and use a xml catalog to make the re-references when parsing
> > schemas with SchemaFactory. It goes well for most of the referenced
> > schemas, except when it comes to a particular schema:
> >
> http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
> .
> > For some reason the local copy I'm re-referencing to is not enough to
> > make the schema validate. I'm getting the following error when
> > SchemaFactory tries to parse it:
> >
> > org.xml.sax.SAXParseException: schema_reference.4: Failed to read
> > schema document 'file:/path/to/xmldsig-core/xmldsig-core-schema.xsd',
> > because 1) could not find the document; 2) the document could not be
> > read; 3) the root element of the document is not <xsd:schema>.
> >
> > The schema is imported the following way from one of the schemas I use:
> >
> > <import namespace="http://www.w3.org/2000/09/xmldsig#"
> >             schemaLocation="http://www.w3.org/TR/xmldsig-
> > core/xmldsig-core-schema.xsd"/>
> >
> > I'm suspecting the problem might have something to do with the
> > namespace, which contains the '#' symbol? The xmldsig-core-schema does
> > not import any schemas itself.
> >
> > I've tried using a rewrite like this:
> > <rewriteSystem systemIdStartString="http://www.w3.org/TR/xmldsig-core/"
> > rewritePrefix="file:///path/to/xmldsig-core/"/>
> >
> > and I've also tried a systemId:
> > <system systemId="
> http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
> > uri="/path/to/xmldsig-core/xmldsig-core-schema.xsd"/>
> >
> > No matter how I seem to make the catalog I get the SAXParseException
> > when SchemaFactory tries to parse the local xmldsig-core.schema file.
> > All schemas are validated without any problems without the catalog.
> >
> > How is it possible to correct the catalog to solve the problem?
> >
> > Thanks,
> > Simon
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Use of XMLCatalogResolver

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Simon,

"file:/path/to/xmldsig-core/xmldsig-core-schema.xsd" seems like the correct
result for the "rewriteSystem" you wrote. What are you expecting to get as
the resolved URI from the catalog resolver? Have you tried opening an
InputStream for this URI yourself with java.net.URL?

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Simon Bøggild" <si...@gmail.com> wrote on 12/02/2007 02:06:23 PM:

> Hi,
>
> I'm trying to use XMLCatalogResolver as the ResourceResolver for a
> SchemaFactory when validating schemas. I've created a catalog file
> following the
http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
> .
> In the schemas that I check I have references to external schemas on
> the Internet, which is why I'm interested in keeping a local copy of
> those, and use a xml catalog to make the re-references when parsing
> schemas with SchemaFactory. It goes well for most of the referenced
> schemas, except when it comes to a particular schema:
>
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
.
> For some reason the local copy I'm re-referencing to is not enough to
> make the schema validate. I'm getting the following error when
> SchemaFactory tries to parse it:
>
> org.xml.sax.SAXParseException: schema_reference.4: Failed to read
> schema document 'file:/path/to/xmldsig-core/xmldsig-core-schema.xsd',
> because 1) could not find the document; 2) the document could not be
> read; 3) the root element of the document is not <xsd:schema>.
>
> The schema is imported the following way from one of the schemas I use:
>
> <import namespace="http://www.w3.org/2000/09/xmldsig#"
>             schemaLocation="http://www.w3.org/TR/xmldsig-
> core/xmldsig-core-schema.xsd"/>
>
> I'm suspecting the problem might have something to do with the
> namespace, which contains the '#' symbol? The xmldsig-core-schema does
> not import any schemas itself.
>
> I've tried using a rewrite like this:
> <rewriteSystem systemIdStartString="http://www.w3.org/TR/xmldsig-core/"
> rewritePrefix="file:///path/to/xmldsig-core/"/>
>
> and I've also tried a systemId:
> <system systemId="
http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
> uri="/path/to/xmldsig-core/xmldsig-core-schema.xsd"/>
>
> No matter how I seem to make the catalog I get the SAXParseException
> when SchemaFactory tries to parse the local xmldsig-core.schema file.
> All schemas are validated without any problems without the catalog.
>
> How is it possible to correct the catalog to solve the problem?
>
> Thanks,
> Simon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org