Jeff is right that the processor can ignore all but the first schema thats imported, but in my work I have the same "problem" as Duane, since we like to fragment the type definitions and element declarations into different schema modules. I sometime use XMLSpy, which certainly has it flaws, but it does "respect" all the imports and as such works great for me. I was wondering how hard it would be to make my own implementation that makes xerces do what I want. From the Grammar faq I get the following:
<quote src="http://xml.apache.org/xerces2-j/faq-grammars.html#faq-2"> Xerces uses hashing to distinguish different grammar objects, by hashing on the XMLGrammarDescription objects that those grammars contain. Thus, both of Xerces implementations of XMLGrammarDescription--for DTD's and XML Schemas--provide implemetations of hashCode(): int and equals(Object):boolean that are used by the hashing algorithm. In XML Schemas, hashing is simply carried out on the target namespace of the schema. Thus, two grammars are considered equal (by our default implementation) if and only if their XMLGrammarDescriptions are instances of org.apache.xerces.impl.xs.XSDDescription (our schema implementation of XMLGrammarDescription) and the targetNamespace fields of those objects are identical. </quote> So I'll need to implement my own XMLGrammarDescription that has a hashCode() that enables multiple grammars per namespace. Have any of you tried this or any idea how had it will be, not beeing a java or xerces whizz. Best regards Brian Nielsen -----Oprindelig meddelelse----- Fra: Jeff Greif [mailto:[EMAIL PROTECTED] Sendt: 16. juni 2004 01:54 Til: [EMAIL PROTECTED]; [EMAIL PROTECTED] Emne: Re: Xerces 2.6.2: Importing multiple XSD's with the same namespace I believe what you are doing is illegal. An import declaration <import namespace="X" schemaLocation="Y"/> tells the schema processor something like "Components from the namespace X might be found at schemaLocation Y". If you have multiple imports of the same namespace, the schema processor is allowed to ignore any of them, and certainly to stop at the first one where the expected document is found (and thus not know that more components might be found in one of the other imports.) You should collect together the various subschemas for namespace X using <include> and then import the result: intermediate.xsd: <schema targetNamespace="X" ...> <include schemaLocation="foo.xsd"/> <include schemaLocation="bar.xsd"/> ... </schema> <schema targetNamespace="http://www.ean-ucc.org/schemas/1.3.1/eanucc" ...> <import namespace="X" schemaLocation="intermediate.xsd"/> ... </schema> Jeff ----- Original Message ----- From: "Duane Jung" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 15, 2004 2:47 PM Subject: Re: Xerces 2.6.2: Importing multiple XSD's with the same namespace > Hi, > > I have some more information. I tried a test where I created an additional schema > (intermediate.xsd) in the abc namespace. In that schema, I included the 10 abc schema files. > > Then in the top level xsd that I imported intermediate.xsd using the abc namespace -- i.e. I did > only one import with the abc namespace. This validated without any problems. > > It seems that there might be a bug that prevents importing multiple schema's using the same > namespace or this convention violates the schema standard. Does anyone know? > > Thanks, Duane > > --- Duane Jung <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm trying to validate an XML using an XSD that has multiple imports with the same namespace. > > An > > example XSD is below: I am importing 10 schemas using the abc namespace. > > > > The problem is that when I look at the SystemId's from a custom EntityResolver, I only see the > > first XSD for the abc namespace being resolved. If I juggle the order of the abc imports, than > > I > > will always see the first one -- I think I am getting parsing errors because the other 9 schemas > > are not being resolved. I am parsing using just validation and schema features. My XML > > validates > > against the XSD fine using XMLSpy and Oracle XDR. > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > <xsd:schema targetNamespace="http://www.ean-ucc.org/schemas/1.3.1/eanucc" > > xmlns="http://www.ean-ucc.org/schemas/1.3.1/eanucc" > > xmlns:eanucc="http://www.ean-ucc.org/schemas/1.3.1/eanucc" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > <xsd:include schemaLocation="As2Envelope.xsd"/> > > <xsd:include schemaLocation="DocumentCommand.xsd"/> > > <xsd:include schemaLocation="Transaction.xsd"/> > > <xsd:include schemaLocation="CatalogueItemNotification.xsd"/> > > <xsd:import namespace="http://www.ean-ucc.org/schemas/1.3.1/fmcg" > > schemaLocation="FmcgIdentification.xsd"/> > > <xsd:import namespace="http://www.ean-ucc.org/schemas/1.3.1/fmcg" > > schemaLocation="FmcgItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_Identification.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_TradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_TM_BelgiumTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_TM_BrazilTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_TM_FranceTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_TM_SwedenTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_GPC_ElectronicsAndAppliancesTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_GPC_FmcgTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_GPC_MusicAndMoviePublishingTradeItem.xsd"/> > > <xsd:import namespace="http://www.abc.org/wim/schemas/3.0/abc" > > schemaLocation="ABC_GPC_PharmacyTradeItem.xsd"/> > > <xsd:import namespace="http://www.uccnet.org/schemas/1.3/hardlines" > > schemaLocation="UCCnet_GPC_HardlinesTradeItem.xsd"/> > > <xsd:import namespace="http://www.uccnet.org/schemas/1.3/hbc" > > schemaLocation="UCCnet_GPC_HBCTradeItem.xsd"/> > > <xsd:import namespace="http://www.uccnet.org/schemas/1.3/otc" > > schemaLocation="UCCnet_GPC_OTCTradeItem.xsd"/> > > <xsd:import namespace="http://www.uccnet.org/schemas/1.3/produce" > > schemaLocation="UCCnet_GPC_ProduceTradeItem.xsd"/> > > </xsd:schema> > > > > ____________________________ > > SystemID's in the order that they registered for when ABC_Identification.xsd is the first abc > > namespace import. > > URL: file:/C:/xerces-2_6_2/samples/sax/ABC_CatalogueItemNotificationProxy.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/As2Envelope.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Identification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/ExtendedTypes.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/DocumentCommand.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Command.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Components.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Identification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Transaction.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Command.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/CatalogueItemNotification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/CatalogueItemComponents.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Components.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/TradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/TradeItemComponents.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Terms.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Components.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/FmcgIdentification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/ABC_Identification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_HardlinesTradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_HBCTradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_OTCTradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_ProduceTradeItem.xsd > > > > ____________________________ > > SystemID's in the order that they registered for when ABC_TradeItem.xsd is the first abc > > namespace > > import. (ABC_TradeItem is being resolved now instead of ABC_Identification). > > > > URL: file:/C:/xerces-2_6_2/samples/sax/ABC_CatalogueItemNotificationProxy.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/As2Envelope.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Identification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/ExtendedTypes.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/DocumentCommand.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Command.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Components.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Identification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Transaction.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Command.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/CatalogueItemNotification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/CatalogueItemComponents.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Components.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/TradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/TradeItemComponents.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Terms.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/Components.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/FmcgIdentification.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/ABC_TradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_HardlinesTradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_HBCTradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_OTCTradeItem.xsd > > URL: file:/C:/xerces-2_6_2/samples/sax/UCCnet_GPC_ProduceTradeItem.xsd > > > > Has anyone seen this issue before? It causing cvc-elt.4.2 errors during parsing. > > cvc-elt.4.2 element is not locally valid, it has xsi:type but the value does not resolve to a > > known type. [Should also have a cvc-resolve-instance error.] > > > > > > Thanks in advance, Duane > > > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > New and Improved Yahoo! Mail - Send 10MB messages! > > http://promotions.yahoo.com/new_mail > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > __________________________________ > Do you Yahoo!? > Read only the mail you want - Yahoo! Mail SpamGuard. > http://promotions.yahoo.com/new_mail > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]