Package org.apache.xerces.xni.parser

Examples of org.apache.xerces.xni.parser.XMLInputSource


            path = path + xsdName;
            requestContext.setResourcePath(new ResourcePath(path));
            WSDLValidationInfo validationInfo = null;
            try {
                if (!disableSchemaValidation) {
                    validationInfo = SchemaValidator.validate(new XMLInputSource(null, uri, null));
                }
            } catch (Exception e) {
                throw new RegistryException("Exception occured while validating the schema" , e);
            }
            SchemaProcessor schemaProcessor =
View Full Code Here


        public void put(URI uri, byte[] bytes) {
            _schemas.put(uri.toASCIIString(), bytes);
        }

        public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
            XMLInputSource src = new XMLInputSource(resourceIdentifier);
            String location = "";
            if (resourceIdentifier.getNamespace() != null && _schemas.get(resourceIdentifier.getNamespace()) != null)
                location = resourceIdentifier.getNamespace();
            else if (resourceIdentifier.getLiteralSystemId() != null && _schemas.get(resourceIdentifier.getLiteralSystemId()) != null)
                location = resourceIdentifier.getLiteralSystemId();
            else if (resourceIdentifier.getExpandedSystemId() != null && _schemas.get(resourceIdentifier.getExpandedSystemId()) != null)
                location = resourceIdentifier.getExpandedSystemId();
            else {
                if (__log.isDebugEnabled()) {
                    __log.debug("Available schemas " + _schemas.keySet());
                }
                throw new IllegalStateException("Schema " + resourceIdentifier + " not captured");
            }

            src.setByteStream(new ByteArrayInputStream(_schemas.get(location)));
            return src;
        }
View Full Code Here

      buf.append(", publicId=");
      buf.append(resourceIdentifier.getPublicId());
      __log.debug(buf.toString());
    }

    XMLInputSource src = _resolver.resolveEntity(resourceIdentifier);
    InputStream is = src.getByteStream();

    if (is == null) {
      __log.debug("resolveEntity: stream not available for: " + src);
      throw new IOException("Unable to locate resource for namespace " + resourceIdentifier.getNamespace());
    }
View Full Code Here

  public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
     throws XNIException, IOException {
  String systemId = resourceIdentifier.getExpandedSystemId();  
  String publicId = resourceIdentifier.getPublicId()
  String namespace = resourceIdentifier.getNamespace();
  XMLInputSource is = null;
  String schema = null;
  if (systemId == null)
  {
    if(publicId == null)
    {
      if(namespace == null)
      { 
        return null;
      }
      else
      {
        systemId = namespace;
      }
    }
    else
   
      systemId = publicId;
    }
  }
   
  if(referringSchemaNamespace != null && referringSchemaNamespace.equals(systemId))
  {
    if(referringSchemaInputSource!=null)
    {
      return referringSchemaInputSource;
    }
  }
  else if ((schema = (String) entities.get(systemId)) != null && !schema.equals(""))
  {
    is = new XMLInputSource(publicId, referringSchemaInputSource.getSystemId() + INLINE_SCHEMA_ID, null, new StringReader(schema),null);
  }
 
    //if(is == null)
    //{
    //  throw new IOException();
View Full Code Here

    String systemId = resourceIdentifier.getLiteralSystemId();
    String location = XMLCatalog.getInstance().resolveEntityLocation(publicId, systemId);
    if (location != null)
    {
      LazyURLInputStream is = new LazyURLInputStream(location);
      XMLInputSource inputSource = new XMLInputSource(publicId, systemId, systemId, is, null);
      return inputSource;
    }
    // otherwise return null to tell the parser to locate the systemId as a URI
    return null;
  }
View Full Code Here

      // If we're currently examining a subelement of the
    // WSDL or schema documentation element we don't want to resolve it
    // as anything is allowed as a child of documentation.
    if(isChildOfDoc)
    {
      return new XMLInputSource(rid);
    }
   
    boolean nsUsed = false;
   
    String ns = rid.getNamespace();
    if(ns != null && ignoredNamespaceList.contains(ns))
    {
    return new XMLInputSource(rid);
    }
   
    String systemId = rid.getLiteralSystemId();
    if(systemId == null)
    {
    systemId = ns;
    nsUsed = true;
    }
    String publicId = rid.getPublicId();
      if(publicId == null)
      {
        publicId = systemId;
      }
     
      // Xerces tends to try to resolve locations with no information.
      // No need to do any processing if we have no information.
      if(publicId != null || systemId != null)
      {
        IURIResolutionResult result = uriResolver.resolve("", publicId, systemId);
        String uri = result.getPhysicalLocation();
        if (uri != null && !uri.equals(""))
        {
          // If the namespace was used to resolve this reference ensure a schema
          // has been returned. Namespaces tend to point to Web resources that
          // may or may not be schemas.
          boolean createEntityResult = true;
          if(nsUsed)
          {
          XSDValidator xsdVal = new XSDValidator();
          xsdVal.validate(uri, uriResolver, null);
          if(!xsdVal.isValid())
            createEntityResult = false;
          }
         
          if(createEntityResult)
          {
          try
          {
          URL entityURL = new URL(uri);
              XMLInputSource is = new XMLInputSource(rid.getPublicId(), systemId, result.getLogicalLocation());
          is.setByteStream(entityURL.openStream());
              if (is != null)
              {
                return is;
              }
          }
View Full Code Here

      grammarPreparser.setEntityResolver(entityResolver);
    }

    try
    {
      XMLInputSource is = null;
      List oldGrammars = null;
      XMLGrammarPoolImpl pool = null;
      // This allows support for the inline schema in WSDL documents.
      if (inlineXSD)
      {      
        Reader reader = new StringReader(schema);
      is = new XMLInputSource(null,filelocation,filelocation,reader,null);
       
      ((InlineXSDResolver)inlineSchemaEntityResolver).addReferringSchema(is,targetNamespace);
      // In the case that 'shared' grammar pool is used we need to consider
      // that we might have already added a schema to the pool with the same target namespace
      // as the inline schema we're hoping to construct.  In this case we need to remove
      // the schema from the pool before constructing our inline schema.  We can add it
      // back when we're all done.
      pool = (XMLGrammarPoolImpl)grammarPreparser.getGrammarPool();               
      oldGrammars = new ArrayList();
      // Remove the inline schema namespace if it is listed directly
      // in the pool. If it is indirectly listed as an import of a grammar listed
      // directly in the pool hide the grammar to continue to get caching benefits
      // from the cached grammar.
      Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
      int numGrammars = grammars.length;
      for(int i = 0; i < numGrammars; i++)
      {
        XMLGrammarDescription desc = grammars[i].getGrammarDescription();
        if(targetNamespace.equals(desc.getNamespace()))
        {
          oldGrammars.add(pool.removeGrammar(desc));
        }
        else
        {
          if(grammars[i] instanceof XSGrammar)
          {
          XSGrammar grammar = (XSGrammar)grammars[i];
               
          StringList namespaces = grammar.toXSModel().getNamespaces();
          if(namespaces.contains(targetNamespace))
          {
            oldGrammars.add(pool.removeGrammar(desc));
                  //pool.putGrammar(new XSGrammarHider(grammar, targetNamespace));
          }
          }
        }
      }
         
      Set inlineNSs = ((InlineXSDResolver)inlineSchemaEntityResolver).getInlineSchemaNSs();
      Iterator nsiter = inlineNSs.iterator();
      while(nsiter.hasNext())
      {
        XSDDescription desc = new XSDDescription();
        desc.setNamespace((String)nsiter.next());     
        Grammar oldGrammar = pool.removeGrammar(desc);
        if(oldGrammar != null)
          oldGrammars.add(oldGrammar);
      }

      }
      // get the input source for an external schema file
      else
      {
        is = new XMLInputSource(null,schema,schema);
      }

      XSGrammar grammar = (XSGrammar)grammarPreparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,is);
      xsModel = grammar.toXSModel();
     
View Full Code Here

      url = namespace;
    }
    if(url != null)
    {
      InputStream is = new LazyURLInputStream(url);
      return new XMLInputSource(publicId, resource.getExpandedSystemId(), resource.getExpandedSystemId(), is, null);
    }
    return null;
  }
View Full Code Here

  /**
   * @see org.apache.xerces.xni.parser.XMLEntityResolver#resolveEntity(org.apache.xerces.xni.XMLResourceIdentifier)
   */
  public XMLInputSource resolveEntity(XMLResourceIdentifier xmlResourceIdentifier) throws XNIException, IOException
  {
    XMLInputSource is = null;
   
    // TODO: This fix should be removed once this problem is fixed in Xerces.
    // Xerces currently (version 2.7) has a problem when the honour all schema locations
    // property is set and the same schema is imported by two different files and one
    // of the imports uses \ and another uses / in part of the location.
View Full Code Here

    if (publicId == null || publicId.equals(""))
    {
      publicId = resourceIdentifier.getNamespace();
    }
    IURIResolutionResult result = resolve(resourceIdentifier.getBaseSystemId(), publicId, systemId);
    XMLInputSource xmlInputSource = null;
    if (result != null)
    {
      LazyURLInputStream is = new LazyURLInputStream(result.getPhysicalLocation());
      xmlInputSource = new XMLInputSource(publicId, result.getLogicalLocation(), result.getLogicalLocation(), is, null);
    }
    return xmlInputSource;
  }
View Full Code Here

TOP

Related Classes of org.apache.xerces.xni.parser.XMLInputSource

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.