Package org.apache.xerces.impl.xs

Examples of org.apache.xerces.impl.xs.XMLSchemaLoader


   public JBossXSModel parseSchema(URL xsdURL)
   {
      JBossXSErrorHandler xserr = new JBossXSErrorHandler();
      JBossWSEntityResolver resolver = new JBossWSEntityResolver();
      JBossXSEntityResolver xsresolve = new JBossXSEntityResolver(resolver, new HashMap<String, URL>());
      XMLSchemaLoader loader = (XMLSchemaLoader)schemautils.getXSLoader(xserr, xsresolve);

      XSModel xsmodel = loader.loadURI(xsdURL.toExternalForm());
      if (xsmodel == null)
         throw new WSException("Cannot load schema: " + xsdURL);

      WSSchemaUtils sutils = WSSchemaUtils.getInstance(null, null);
      JBossXSModel jbxs = new JBossXSModel();
View Full Code Here


         throw new IllegalArgumentException("Illegal schema location map");

      JBossXSErrorHandler xserr = new JBossXSErrorHandler();
      JBossWSEntityResolver resolver = new JBossWSEntityResolver();
      JBossXSEntityResolver xsresolve = new JBossXSEntityResolver(resolver, locs);
      XMLSchemaLoader loader = (XMLSchemaLoader)schemautils.getXSLoader(xserr, xsresolve);

      int index = 0;
      SchemaGrammar[] gs = new SchemaGrammar[locs.size()];
      Iterator<String> it = locs.keySet().iterator();
      while (it.hasNext())
      {
         InputStream in = null;
         try
         {
            String nsURI = it.next();
            URL orgURL = locs.get(nsURI);
            URL resURL = resolveNamespaceURI(resolver, nsURI);
            URL url = resURL != null ? resURL : orgURL;
           
            log.debug("Load schema: " + nsURI + "=" + url);
            XMLInputSource inputSource = new XMLInputSource(null, url.toExternalForm(), null);

            InputSource tmpSrc = resolver.resolveEntity(null, url.toExternalForm());
            in = tmpSrc.getByteStream() != null ? tmpSrc.getByteStream() : new ResourceURL(url).openStream();
            inputSource.setByteStream(in);
           
            SchemaGrammar grammar = (SchemaGrammar)loader.loadGrammar(inputSource);
            if (grammar == null)
               throw new IllegalStateException("Cannot load grammar: " + url);
           
            gs[index++] = grammar;
         }
View Full Code Here

     * @param schemas collection of schemas (indexed by systemId)
     *
     * @return a {@link SchemaModel}
     */
    public static final SchemaModel newModel(Map<URI, byte[]> schemas) {
        XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
        InternalSchemaResolver resolver = new InternalSchemaResolver();
        schemaLoader.setEntityResolver(resolver);
        schemaLoader.setParameter(Constants.DOM_ERROR_HANDLER, new SchemaErrorHandler());


        final String[] uris = new String[schemas.size()];
        final byte[][] content = new byte[schemas.size()][];

        int idx = 0;
        for (Iterator<Map.Entry<URI,byte[]>> i = schemas.entrySet().iterator();i.hasNext();) {
            Map.Entry<URI, byte[]> me = i.next();
            uris[idx] = me.getKey().toASCIIString();
            content[idx] = me.getValue();
            resolver.put(me.getKey(), me.getValue());
            ++idx;
        }

        LSInputList list = new LSInputList() {
            public LSInput item(int index) {
                DOMInputImpl input = new DOMInputImpl();
                input.setSystemId(uris[index]);
                input.setByteStream(new ByteArrayInputStream(content[index]));
                return input;
            }

            public int getLength() {
                return uris.length;
            }
        };

        XSModel xsm = schemaLoader.loadInputList(list);
        return new SchemaModelImpl(xsm);
    }
View Full Code Here

    *
    * @return
    */
   public XSLoader getXSLoader()
   {
      XMLSchemaLoader xsloader = new XMLSchemaLoader();
      JBossXSErrorHandler eh = new JBossXSErrorHandler();
      xsloader.setErrorHandler(eh);
      xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
      return xsloader;
   }
View Full Code Here

    * @param xer XML Entity Resolver
    * @return
    */
   public XSLoader getXSLoader(XMLErrorHandler xeh, XMLEntityResolver xer)
   {
      XMLSchemaLoader xsloader = new XMLSchemaLoader();
      xsloader.setEntityResolver(xer);
      xsloader.setErrorHandler(xeh);
      xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
      return xsloader;
   }
View Full Code Here

/* 373 */     return xt;
/*     */   }
/*     */
/*     */   public XSLoader getXSLoader()
/*     */   {
/* 384 */     XMLSchemaLoader xsloader = new XMLSchemaLoader();
/* 385 */     JBossXSErrorHandler eh = new JBossXSErrorHandler();
/* 386 */     xsloader.setErrorHandler(eh);
/* 387 */     xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
/* 388 */     return xsloader;
/*     */   }
View Full Code Here

/* 388 */     return xsloader;
/*     */   }
/*     */
/*     */   public XSLoader getXSLoader(XMLErrorHandler xeh, XMLEntityResolver xer)
/*     */   {
/* 400 */     XMLSchemaLoader xsloader = new XMLSchemaLoader();
/* 401 */     xsloader.setEntityResolver(xer);
/* 402 */     xsloader.setErrorHandler(xeh);
/* 403 */     xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
/* 404 */     return xsloader;
/*     */   }
View Full Code Here

/*     */   public JBossXSModel parseSchema(URL xsdURL)
/*     */   {
/* 133 */     JBossXSErrorHandler xserr = new JBossXSErrorHandler();
/* 134 */     JBossWSEntityResolver resolver = new JBossWSEntityResolver();
/* 135 */     JBossXSEntityResolver xsresolve = new JBossXSEntityResolver(resolver, new HashMap());
/* 136 */     XMLSchemaLoader loader = (XMLSchemaLoader)this.schemautils.getXSLoader(xserr, xsresolve);
/*     */
/* 138 */     XSModel xsmodel = loader.loadURI(xsdURL.toExternalForm());
/* 139 */     if (xsmodel == null) {
/* 140 */       throw new WSException("Cannot load schema: " + xsdURL);
/*     */     }
/* 142 */     WSSchemaUtils sutils = WSSchemaUtils.getInstance(null, null);
/* 143 */     JBossXSModel jbxs = new JBossXSModel();
View Full Code Here

/* 156 */       throw new IllegalArgumentException("Illegal schema location map");
/*     */     }
/* 158 */     JBossXSErrorHandler xserr = new JBossXSErrorHandler();
/* 159 */     JBossWSEntityResolver resolver = new JBossWSEntityResolver();
/* 160 */     JBossXSEntityResolver xsresolve = new JBossXSEntityResolver(resolver, locs);
/* 161 */     XMLSchemaLoader loader = (XMLSchemaLoader)this.schemautils.getXSLoader(xserr, xsresolve);
/*     */
/* 163 */     int index = 0;
/* 164 */     SchemaGrammar[] gs = new SchemaGrammar[locs.size()];
/* 165 */     Iterator it = locs.keySet().iterator();
/* 166 */     while (it.hasNext())
/*     */     {
/*     */       try
/*     */       {
/* 170 */         String nsURI = (String)it.next();
/* 171 */         URL orgURL = (URL)locs.get(nsURI);
/* 172 */         URL resURL = resolveNamespaceURI(resolver, nsURI);
/* 173 */         URL url = resURL != null ? resURL : orgURL;
/*     */
/* 175 */         log.debug("Load schema: " + nsURI + "=" + url);
/* 176 */         XMLInputSource inputSource = new XMLInputSource(null, url.toExternalForm(), null);
/*     */
/* 178 */         InputSource tmpSrc = resolver.resolveEntity(null, url.toExternalForm());
/* 179 */         InputStream in = tmpSrc.getByteStream() != null ? tmpSrc.getByteStream() : new ResourceURL(url).openStream();
/* 180 */         inputSource.setByteStream(in);
/*     */
/* 182 */         SchemaGrammar grammar = (SchemaGrammar)loader.loadGrammar(inputSource);
/* 183 */         if (grammar == null) {
/* 184 */           throw new IllegalStateException("Cannot load grammar: " + url);
/*     */         }
/* 186 */         gs[(index++)] = grammar;
/*     */       }
View Full Code Here

        // add default recognized features
        // set state for default features
        // add default recognized properties
        // create and register missing components
        fSchemaLoader = new XMLSchemaLoader(fSymbolTable);
        fSchemaLoader.setProperty(XMLGRAMMAR_POOL, fGrammarPool);

        // and set up the DTD loader too:
        fDTDLoader = new XMLDTDLoader(fSymbolTable, fGrammarPool);
    } // <init>(SymbolTable,XMLGrammarPool, XMLComponentManager)
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xs.XMLSchemaLoader

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.