Package org.apache.xerces.xni.parser

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


        xsdStream.close();
    }

    Map<URI, byte[]> s = XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
        public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
            XMLInputSource src = new XMLInputSource(resourceIdentifier);
            String literalUri = resourceIdentifier.getLiteralSystemId();

            if (literalUri != null) {
              src.setByteStream(getClass().getClassLoader().getResourceAsStream(literalUri));
            }

            return src;
        }
    });
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, systemId, systemId,new StringReader(schema),null);
  }
 
    //if(is == null)
    //{
    //  throw new IOException();
View Full Code Here

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

    grammarPreparser.setEntityResolver(entityResolver);
      }

      try
      {
    XMLInputSource is = 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);

        }
        // get the input source for an external schema file
        else
        {
          is = new XMLInputSource(null,schema,schema);
        }
       
        grammarPreparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA,null/*schemaLoader*/);
        grammarPreparser.getLoader(XMLGrammarDescription.XML_SCHEMA);

View Full Code Here

      url = resource.getNamespace();
    }
    if(url != null)
    {
      InputStream is = new LazyURLInputStream(url);
      return new XMLInputSource(publicId, systemId, systemId, 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;
    Iterator entityResolverIter = entityResolvers.iterator();
    while (entityResolverIter.hasNext())
    {
      XMLEntityResolver entityResolver = (XMLEntityResolver)entityResolverIter.next();
      try
View Full Code Here

    public void endElement(QName element, Augmentations augs) throws XNIException {
      if (currentOsmlTag != null && "script".equalsIgnoreCase(element.rawname)) {
        QName endingTag = currentOsmlTag;
        currentOsmlTag = null;

        XMLInputSource scriptSource = new XMLInputSource(null, null, null);
        scriptSource.setCharacterStream(new StringReader(scriptContent.toString()));
        scriptContent.setLength(0);

        // Evaluate the content of the script block immediately
        scanner.evaluateInputSource(scriptSource);
View Full Code Here

    htmlScanner.setDocumentHandler(tagBalancer);

    tagBalancer.reset(config);
    htmlScanner.reset(config);

    XMLInputSource inputSource = new XMLInputSource(null, null, null);
    inputSource.setEncoding("UTF-8");
    inputSource.setCharacterStream(new StringReader(source));
    htmlScanner.setInputSource(inputSource);
    htmlScanner.scanDocument(true);
    return handler;
  }
View Full Code Here

   * @param in InputStream of XML schema
   */
  public void updateXSDInfo(String uri,Reader in){
    try {
      SchemaGrammar grammer = (SchemaGrammar)new XMLSchemaLoader().loadGrammar(
          new XMLInputSource(null,null,null,in,null));
     
      // clear at first
      String targetNS = grammer.getTargetNamespace();
      nsTagListMap.put(targetNS,new ArrayList());
      List tagList = (List)nsTagListMap.get(targetNS);
View Full Code Here

      DTDResolver resolver = new DTDResolver(new IDTDResolver[0],
          getFile().getLocation().makeAbsolute().toFile().getParentFile());
      InputStream in = resolver.getInputStream(this.schemaURI);
      if(in!=null){
        SchemaGrammar grammer = (SchemaGrammar)new XMLSchemaLoader().loadGrammar(
            new XMLInputSource(null,null,null,in,null));
        return grammer.getTargetNamespace();
      }
    } catch(Exception ex){
    }
    return null;
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.