|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
MalformedURLException in sdo-compilerI am trying to run the sdo-compiler against some of the OASIS xsd files
but when I try I get a MalformedURLException when resolving schemas. This is using 1.0M11. The first exception I get is:- [EL Warning]: 2008.07.09 11:41:48.932--Thread(Thread[main,5,main])--An java.net.MalformedURLException occurred processing referenced schema with uri urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 with schemaLocation ../common/UBL-CommonAggregateComponents-2.0.xsd. [EL Finest]: 2008.07.09 11:41:48.947--Thread(Thread[main,5,main])--java.net.MalformedURLException: no protocol: ../common/UBL-CommonAggregateComponents-2.0.xsd at java.net.URL.<init>(URL.java:567) at java.net.URL.<init>(URL.java:464) at java.net.URL.<init>(URL.java:413) at org.eclipse.persistence.sdo.helper.DefaultSchemaResolver.resolveSchema(DefaultSchemaResolver.java:55) at org.eclipse.persistence.sdo.helper.SchemaResolverWrapper.resolveSchema(SchemaResolverWrapper.java:61) at org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getReferencedSchema(SDOTypesGenerator.java:2056) at org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypesGenerator.java:2025) at org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypesGenerator.java:1999) at org.eclipse.persistence.sdo.helper.SDOTypesGenerator.define(SDOTypesGenerator.java:108) at org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassGenerator.java:209) at org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassGenerator.java:175) at org.eclipse.persistence.sdo.helper.SDOClassGenerator.main(SDOClassGenerator.java:111) Looking at the relevant line in the xsd file, it starts:- <?xml version="1.0" encoding="UTF-8"?> <!-- Document Type: Invoice Generated On: Tue Oct 03 2:26:38 P3 2006 --> <!-- ===== xsd:schema Element With Namespaces Declarations ===== --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.0"> <!-- ===== Imports ===== --> <xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" schemaLocation="../common/UBL-CommonAggregateComponents-2.0.xsd"/> and I think it is complaining about schemaLocation. I guess this is because of the lack of a protocol. I am using Sun Java 6 on linux, using its default XML code. Perhaps the code in DefaultSchemaResolver needs to trap this exception and try adding file:/// to the front of the URL. I do not know whether this is really a fault with the OASIS xsd file but they have been in the field for a while and I am sure of XML parsers generally objected to this it would have been picked up as a problem. In fact looking at the code, should DefaultSchemaResolver.java line 55 which currently reads:- schemaUrl = new URL(schemaLocation); read instead:- schemaUrl = new URI(schemaLocation).toUrl(); as the javadoc for URI says that it can handle this kind of specification without a protocol. David _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compilerOn Wednesday 09 July 2008, David Goodenough wrote:
> I am trying to run the sdo-compiler against some of the OASIS xsd files > but when I try I get a MalformedURLException when resolving schemas. > > This is using 1.0M11. > > The first exception I get is:- > > [EL Warning]: 2008.07.09 11:41:48.932--Thread(Thread[main,5,main])--An > java.net.MalformedURLException occurred processing referenced schema with > uri > urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 > with schemaLocation ../common/UBL-CommonAggregateComponents-2.0.xsd. > [EL Finest]: 2008.07.09 > 11:41:48.947--Thread(Thread[main,5,main])--java.net.MalformedURLException: > no protocol: ../common/UBL-CommonAggregateComponents-2.0.xsd > at java.net.URL.<init>(URL.java:567) > at java.net.URL.<init>(URL.java:464) > at java.net.URL.<init>(URL.java:413) > at > org.eclipse.persistence.sdo.helper.DefaultSchemaResolver.resolveSchema(Defa >ultSchemaResolver.java:55) at > org.eclipse.persistence.sdo.helper.SchemaResolverWrapper.resolveSchema(Sche >maResolverWrapper.java:61) at > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getReferencedSchema(SD >OTypesGenerator.java:2056) at > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypesGene >rator.java:2025) at > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypesGene >rator.java:1999) at > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.define(SDOTypesGenerat >or.java:108) at > org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassGener >ator.java:209) at > org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassGener >ator.java:175) at > org.eclipse.persistence.sdo.helper.SDOClassGenerator.main(SDOClassGenerator >.java:111) > > Looking at the relevant line in the xsd file, it starts:- > > <?xml version="1.0" encoding="UTF-8"?> > <!-- > Document Type: Invoice > Generated On: Tue Oct 03 2:26:38 P3 2006 > > --> > <!-- ===== xsd:schema Element With Namespaces Declarations ===== --> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" > xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" > xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComp >onents-2" > xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponen >ts-2" > xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSch >emaModule:2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" > > xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComp >onents-2" > xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes- >2" elementFormDefault="qualified" > attributeFormDefault="unqualified" > version="2.0"> > <!-- ===== Imports ===== --> > <xsd:import > namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComp >onents-2" schemaLocation="../common/UBL-CommonAggregateComponents-2.0.xsd"/> > > and I think it is complaining about schemaLocation. > > I guess this is because of the lack of a protocol. > > I am using Sun Java 6 on linux, using its default XML code. > > Perhaps the code in DefaultSchemaResolver needs to trap this exception and > try adding file:/// to the front of the URL. I do not know whether this is > really a fault with the OASIS xsd file but they have been in the field for > a while and I am sure of XML parsers generally objected to this it would > have been picked up as a problem. > > In fact looking at the code, should DefaultSchemaResolver.java line 55 > which currently reads:- > > schemaUrl = new URL(schemaLocation); > > read instead:- > > schemaUrl = new URI(schemaLocation).toUrl(); > > as the javadoc for URI says that it can handle this kind of specification > without a protocol. https://bugs.eclipse.org/bugs/show_bug.cgi?id=240166 opened. David _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compilerTo handle this scenario you will need to implement a SchemaResolver (org.eclipse.persistence.sdo.helper package) that can load the doc based on the relative path. To do this, you can simply extend the default resolver we provide (org.eclipse.persistence.sdo.helper.DefaultSchemaResolver) and override the resolveSchema(Source, String, String) method to handle this case. Note that the schema resolver is passed in as a parameter in the define method on the delegator. Here's an example of a custom resolver: public class CyclicSchemaResolver extends DefaultSchemaResolver {Please let me know if you have any questions. --Dave David Goodenough wrote:
--
_______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compilerHow do I use this in the sdo-compiler?
David On Wednesday 09 July 2008, David McCann wrote: > Hey David, > > To handle this scenario you will need to implement a SchemaResolver > (org.eclipse.persistence.sdo.helper package) that can load the doc based > on the relative path. To do this, you can simply extend the default > resolver we provide > (org.eclipse.persistence.sdo.helper.DefaultSchemaResolver) and override > the resolveSchema(Source, String, String) method to handle this case. > Note that the schema resolver is passed in as a parameter in the define > method on the delegator. > > Here's an example of a custom resolver: > > public class CyclicSchemaResolver extends DefaultSchemaResolver { > public Source resolveSchema(Source sourceXSD, String namespace, > String schemaLocation) { > if (schemaLocation != null && !schemaLocation.equals("")) { > return super.resolveSchema(sourceXSD, namespace, > schemaLocation); > } > schemaLocation = namespace.equals("uri") ? "Cyclic1.xsd" : > "Cyclic2.xsd"; > URL schemaUrl = null; > try { > if (getBaseSchemaLocation() != null) { > // Attempt to resolve the schema location against > the base location > URI baseUri = new URI(getBaseSchemaLocation()); > URI resolvedUri = baseUri.resolve(schemaLocation); > schemaUrl = resolvedUri.toURL(); > } else { > schemaUrl = new URL(schemaLocation); > } > } catch (Exception e) { > return null; > } > return new StreamSource(schemaUrl.toExternalForm()); > } > } > > Please let me know if you have any questions. > > --Dave > ------------------------------------------------------------------------ > > David Goodenough wrote: > > I am trying to run the sdo-compiler against some of the OASIS xsd files > > but when I try I get a MalformedURLException when resolving schemas. > > > > This is using 1.0M11. > > > > The first exception I get is:- > > > > [EL Warning]: 2008.07.09 11:41:48.932--Thread(Thread[main,5,main])--An > > java.net.MalformedURLException occurred processing referenced schema with > > uri > > urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 > > with schemaLocation ../common/UBL-CommonAggregateComponents-2.0.xsd. > > [EL Finest]: 2008.07.09 > > 11:41:48.947--Thread(Thread[main,5,main])--java.net.MalformedURLException > >: no protocol: ../common/UBL-CommonAggregateComponents-2.0.xsd > > at java.net.URL.<init>(URL.java:567) > > at java.net.URL.<init>(URL.java:464) > > at java.net.URL.<init>(URL.java:413) > > at > > org.eclipse.persistence.sdo.helper.DefaultSchemaResolver.resolveSchema(De > >faultSchemaResolver.java:55) at > > org.eclipse.persistence.sdo.helper.SchemaResolverWrapper.resolveSchema(Sc > >hemaResolverWrapper.java:61) at > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getReferencedSchema( > >SDOTypesGenerator.java:2056) at > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypesGe > >nerator.java:2025) at > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypesGe > >nerator.java:1999) at > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.define(SDOTypesGener > >ator.java:108) at > > org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassGen > >erator.java:209) at > > org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassGen > >erator.java:175) at > > org.eclipse.persistence.sdo.helper.SDOClassGenerator.main(SDOClassGenerat > >or.java:111) > > > > Looking at the relevant line in the xsd file, it starts:- > > > > <?xml version="1.0" encoding="UTF-8"?> > > <!-- > > Document Type: Invoice > > Generated On: Tue Oct 03 2:26:38 P3 2006 > > > > --> > > <!-- ===== xsd:schema Element With Namespaces Declarations ===== --> > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > > > targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" > > xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" > > > > xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateCo > >mponents-2" > > > > xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicCompon > >ents-2" > > > > xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesS > >chemaModule:2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" > > > > xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionCo > >mponents-2" > > > > xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatype > >s-2" elementFormDefault="qualified" > > attributeFormDefault="unqualified" > > version="2.0"> > > <!-- ===== Imports ===== --> > > <xsd:import > > namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateCo > >mponents-2" > > schemaLocation="../common/UBL-CommonAggregateComponents-2.0.xsd"/> > > > > and I think it is complaining about schemaLocation. > > > > I guess this is because of the lack of a protocol. > > > > I am using Sun Java 6 on linux, using its default XML code. > > > > Perhaps the code in DefaultSchemaResolver needs to trap this exception > > and try adding file:/// to the front of the URL. I do not know whether > > this is really a fault with the OASIS xsd file but they have been in the > > field for a while and I am sure of XML parsers generally objected to this > > it would have been picked up as a problem. > > > > In fact looking at the code, should DefaultSchemaResolver.java line 55 > > which currently reads:- > > > > schemaUrl = new URL(schemaLocation); > > > > read instead:- > > > > schemaUrl = new URI(schemaLocation).toUrl(); > > > > as the javadoc for URI says that it can handle this kind of specification > > without a protocol. > > > > David > > _______________________________________________ > > eclipselink-users mailing list > > eclipselink-users@... > > https://dev.eclipse.org/mailman/listinfo/eclipselink-users _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compilerThat is to say how do I do this using the command sdo-compiler.sh?
Also why does the else below (and that in the default one) use new URL when surely it should use new URI? David On Wednesday 09 July 2008, David Goodenough wrote: > How do I use this in the sdo-compiler? > > David > > On Wednesday 09 July 2008, David McCann wrote: > > Hey David, > > > > To handle this scenario you will need to implement a SchemaResolver > > (org.eclipse.persistence.sdo.helper package) that can load the doc based > > on the relative path. To do this, you can simply extend the default > > resolver we provide > > (org.eclipse.persistence.sdo.helper.DefaultSchemaResolver) and override > > the resolveSchema(Source, String, String) method to handle this case. > > Note that the schema resolver is passed in as a parameter in the define > > method on the delegator. > > > > Here's an example of a custom resolver: > > > > public class CyclicSchemaResolver extends DefaultSchemaResolver { > > public Source resolveSchema(Source sourceXSD, String namespace, > > String schemaLocation) { > > if (schemaLocation != null && !schemaLocation.equals("")) { > > return super.resolveSchema(sourceXSD, namespace, > > schemaLocation); > > } > > schemaLocation = namespace.equals("uri") ? "Cyclic1.xsd" : > > "Cyclic2.xsd"; > > URL schemaUrl = null; > > try { > > if (getBaseSchemaLocation() != null) { > > // Attempt to resolve the schema location against > > the base location > > URI baseUri = new URI(getBaseSchemaLocation()); > > URI resolvedUri = baseUri.resolve(schemaLocation); > > schemaUrl = resolvedUri.toURL(); > > } else { > > schemaUrl = new URL(schemaLocation); > > } > > } catch (Exception e) { > > return null; > > } > > return new StreamSource(schemaUrl.toExternalForm()); > > } > > } > > > > Please let me know if you have any questions. > > > > --Dave > > ------------------------------------------------------------------------ > > > > David Goodenough wrote: > > > I am trying to run the sdo-compiler against some of the OASIS xsd files > > > but when I try I get a MalformedURLException when resolving schemas. > > > > > > This is using 1.0M11. > > > > > > The first exception I get is:- > > > > > > [EL Warning]: 2008.07.09 11:41:48.932--Thread(Thread[main,5,main])--An > > > java.net.MalformedURLException occurred processing referenced schema > > > with uri > > > urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents- > > >2 with schemaLocation ../common/UBL-CommonAggregateComponents-2.0.xsd. > > > [EL Finest]: 2008.07.09 > > > 11:41:48.947--Thread(Thread[main,5,main])--java.net.MalformedURLExcepti > > >on > > > > > >: no protocol: ../common/UBL-CommonAggregateComponents-2.0.xsd > > > > > > at java.net.URL.<init>(URL.java:567) > > > at java.net.URL.<init>(URL.java:464) > > > at java.net.URL.<init>(URL.java:413) > > > at > > > org.eclipse.persistence.sdo.helper.DefaultSchemaResolver.resolveSchema( > > >De faultSchemaResolver.java:55) at > > > org.eclipse.persistence.sdo.helper.SchemaResolverWrapper.resolveSchema( > > >Sc hemaResolverWrapper.java:61) at > > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getReferencedSchem > > >a( SDOTypesGenerator.java:2056) at > > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypes > > >Ge nerator.java:2025) at > > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.getSchema(SDOTypes > > >Ge nerator.java:1999) at > > > org.eclipse.persistence.sdo.helper.SDOTypesGenerator.define(SDOTypesGen > > >er ator.java:108) at > > > org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassG > > >en erator.java:209) at > > > org.eclipse.persistence.sdo.helper.SDOClassGenerator.generate(SDOClassG > > >en erator.java:175) at > > > org.eclipse.persistence.sdo.helper.SDOClassGenerator.main(SDOClassGener > > >at or.java:111) > > > > > > Looking at the relevant line in the xsd file, it starts:- > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <!-- > > > Document Type: Invoice > > > Generated On: Tue Oct 03 2:26:38 P3 2006 > > > > > > --> > > > <!-- ===== xsd:schema Element With Namespaces Declarations ===== --> > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > > > > > targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 > > >" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" > > > > > > xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregate > > >Co mponents-2" > > > > > > xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComp > > >on ents-2" > > > > > > xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataType > > >sS chemaModule:2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" > > > > > > xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtension > > >Co mponents-2" > > > > > > xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataty > > >pe s-2" elementFormDefault="qualified" > > > attributeFormDefault="unqualified" > > > version="2.0"> > > > <!-- ===== Imports ===== --> > > > <xsd:import > > > namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregate > > >Co mponents-2" > > > schemaLocation="../common/UBL-CommonAggregateComponents-2.0.xsd"/> > > > > > > and I think it is complaining about schemaLocation. > > > > > > I guess this is because of the lack of a protocol. > > > > > > I am using Sun Java 6 on linux, using its default XML code. > > > > > > Perhaps the code in DefaultSchemaResolver needs to trap this exception > > > and try adding file:/// to the front of the URL. I do not know whether > > > this is really a fault with the OASIS xsd file but they have been in > > > the field for a while and I am sure of XML parsers generally objected > > > to this it would have been picked up as a problem. > > > > > > In fact looking at the code, should DefaultSchemaResolver.java line 55 > > > which currently reads:- > > > > > > schemaUrl = new URL(schemaLocation); > > > > > > read instead:- > > > > > > schemaUrl = new URI(schemaLocation).toUrl(); > > > > > > as the javadoc for URI says that it can handle this kind of > > > specification without a protocol. > > > > > > David > > > _______________________________________________ > > > eclipselink-users mailing list > > > eclipselink-users@... > > > https://dev.eclipse.org/mailman/listinfo/eclipselink-users > > _______________________________________________ > eclipselink-users mailing list > eclipselink-users@... > https://dev.eclipse.org/mailman/listinfo/eclipselink-users _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compilerpackage test;Make sure this class is on the classpath, and change the following line in the script from: ${JAVA_HOME}/bin/java ${JVM_ARGS} -cp ${CLASSPATH} \to: ${JAVA_HOME}/bin/java ${JVM_ARGS} -cp ${CLASSPATH} \Please let me know if you have any further questions. David Goodenough wrote: How do I use this in the sdo-compiler? David On Wednesday 09 July 2008, David McCann wrote: --
_______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compiler--dave David Goodenough wrote: That is to say how do I do this using the command sdo-compiler.sh? Also why does the else below (and that in the default one) use new URL when surely it should use new URI? David On Wednesday 09 July 2008, David Goodenough wrote: --
_______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
|
|
Re: MalformedURLException in sdo-compiler// SchemaResolver implementation David McCann wrote: The main method code path in SDOClassGenerator uses our default resolver, so you have a few options - modify the schema location(s) [not preferred], write an application and not use the compiler script, or write a custom class generator that uses your custom resolver and execute that from the script instead of the SDOClassGenerator. For example, your custom class generator class could look something like: |