Package org.eclipse.xsd.util

Examples of org.eclipse.xsd.util.XSDSchemaLocationResolver


     * @see org.geotools.xml.XSD#buildSchema()
     */
    @Override
    protected XSDSchema buildSchema() throws IOException {
        schema = Schemas.parse(getSchemaLocation(), Collections.EMPTY_LIST,
                Collections.singletonList(new XSDSchemaLocationResolver() {
                    public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI,
                            String schemaLocationURI) {
                        try {
                            URI contextUri = new URI(xsdSchema.getSchemaLocation());
                            if (contextUri.isOpaque()) {
View Full Code Here


        for (Iterator d = dependencies.iterator(); d.hasNext();) {
            Configuration dependency = (Configuration) d.next();

            //throw locator and location resolver into context
            XSDSchemaLocationResolver resolver = dependency.getSchemaLocationResolver();

            if (resolver != null) {
                QName key = new QName(dependency.getNamespaceURI(), "schemaLocationResolver");
                container.registerComponentInstance(key, resolver);
            }
View Full Code Here

        List resolvers = new ArrayList();

        for (Iterator c = all.iterator(); c.hasNext();) {
            configuration = (Configuration) c.next();

            XSDSchemaLocationResolver resolver = configuration.getSchemaLocationResolver();

            if (resolver != null) {
                resolvers.add(resolver);
            }
        }
View Full Code Here

        }
       
        String resolve( String namespace, String location ) {
            //look for a location resolver capable of handling it
            for ( Iterator r = resolvers.iterator(); r.hasNext(); ) {
                XSDSchemaLocationResolver resolver = (XSDSchemaLocationResolver) r.next();
                if ( resolver instanceof SchemaLocationResolver ) {
                    if ( ((SchemaLocationResolver) resolver ).canHandle(null, namespace,location)) {
                        //can handle, actually resolve and recurse
                        String resolvedSchemaLocation =
                            resolver.resolveSchemaLocation(null, namespace, location );
                        if ( resolvedSchemaLocation != null ) {
                            return resolvedSchemaLocation;
                        }
                        else {
                            //should not happen, but just continue
View Full Code Here

        }

        public String resolveSchemaLocation(XSDSchema schema, String namespaceURI,
            String rawSchemaLocationURI) {
            for (int i = 0; i < resolvers.size(); i++) {
                XSDSchemaLocationResolver resolver = (XSDSchemaLocationResolver) resolvers.get(i);
                String resolved = resolver.resolveSchemaLocation(schema, namespaceURI,
                        rawSchemaLocationURI);

                if (resolved != null) {
                    return resolved;
                }
View Full Code Here

            }
       
    };
   
    //add a location resolver which checks the schema source directory
    XSDSchemaLocationResolver locationResolver = new XSDSchemaLocationResolver() {

      public String resolveSchemaLocation(
        XSDSchema schema, String namespaceURI, String schemaLocation
      ) {
     
                                if ( schemaLocation == null ) {
                                   getLog().warn("Null location for " + namespaceURI );
                                   return null;
                                }
                               
        //check location directlry
        File file = new File( schemaLocation )
        if ( file.exists() ) {
          getLog().debug( "Resolving " + schemaLocation + " to " + schemaLocation );
          return schemaLocation;
        }
       
        String fileName = new File( schemaLocation ).getName();
       
        //check under teh schema source directory
        file = new File( schemaSourceDirectory, fileName );
        if ( file.exists() ) {
          getLog().debug( "Resolving " + schemaLocation + " to " + file.getAbsolutePath() );
          return file.getAbsolutePath();
        }
       
        //check hte lookup directories
        if ( schemaLookupDirectories != null ) {
          for ( int i = 0; i < schemaLookupDirectories.length; i++ ) {
            File schemaLookupDirectory = schemaLookupDirectories[ i ];
            file = new File( schemaLookupDirectory, fileName );
            if ( file.exists() ) {
              getLog().debug( "Resolving " + schemaLocation + " to " + file.getAbsolutePath() );
              return file.getAbsolutePath();
            }
             
          }
        }
       
        getLog().warn( "Could not resolve location for: " + fileName );
        return null;
      }
     
    };
   
    //parse the schema
    XSDSchema xsdSchema = null;
    try {
      getLog().info("Parsing schema: " + schemaLocation);
      if (relativeSchemaReference) {
        xsdSchema = Schemas.parse(schemaLocation.getAbsolutePath(), Collections.EMPTY_LIST,
            Collections.singletonList(new XSDSchemaLocationResolver() {
              public String resolveSchemaLocation(XSDSchema xsdSchema,
                  String namespaceURI, String schemaLocationURI) {
                try {
                  URI contextUri = new URI(xsdSchema.getSchemaLocation());
                  if (contextUri.isOpaque()) {
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.util.XSDSchemaLocationResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.