当前位置: 首页>>代码示例>>Java>>正文


Java XMLInputSource.setCharacterStream方法代码示例

本文整理汇总了Java中org.apache.xerces.xni.parser.XMLInputSource.setCharacterStream方法的典型用法代码示例。如果您正苦于以下问题:Java XMLInputSource.setCharacterStream方法的具体用法?Java XMLInputSource.setCharacterStream怎么用?Java XMLInputSource.setCharacterStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xerces.xni.parser.XMLInputSource的用法示例。


在下文中一共展示了XMLInputSource.setCharacterStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createXMLInputSource

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
 * Creates an XMLInputSource from a SAX InputSource.
 */
private XMLInputSource createXMLInputSource(InputSource source, String baseURI) {
 
    String publicId = source.getPublicId();
    String systemId = source.getSystemId();
    String baseSystemId = baseURI;
    InputStream byteStream = source.getByteStream();
    Reader charStream = source.getCharacterStream();
    String encoding = source.getEncoding();
    XMLInputSource xmlInputSource =
        new XMLInputSource(publicId, systemId, baseSystemId);
    xmlInputSource.setByteStream(byteStream);
    xmlInputSource.setCharacterStream(charStream);
    xmlInputSource.setEncoding(encoding);
    return xmlInputSource;
    
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:20,代码来源:EntityResolver2Wrapper.java

示例2: validateAnnotations

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
private void validateAnnotations(ArrayList annotationInfo) {
    if (fAnnotationValidator == null) {
        createAnnotationValidator();
    }
    final int size = annotationInfo.size();
    final XMLInputSource src = new XMLInputSource(null, null, null);
    fGrammarBucketAdapter.refreshGrammars(fGrammarBucket);
    for (int i = 0; i < size; i += 2) {
        src.setSystemId((String) annotationInfo.get(i));
        XSAnnotationInfo annotation = (XSAnnotationInfo) annotationInfo.get(i+1);
        while (annotation != null) {
            src.setCharacterStream(new StringReader(annotation.fAnnotation));
            try {
                fAnnotationValidator.parse(src);
            }
            catch (IOException exc) {}
            annotation = annotation.next;
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:21,代码来源:XSDHandler.java

示例3: endElement

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
@Override
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);

    super.endElement(endingTag, augs);
  } else {
    super.endElement(element, augs);
  }
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:19,代码来源:NekoSimplifiedHtmlParser.java

示例4: toXMLInputSource

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
private static XMLInputSource toXMLInputSource(InputSource in) {
  XMLInputSource xin = new XMLInputSource(in.getPublicId(), in.getSystemId(), null);
  xin.setByteStream(in.getByteStream());
  xin.setCharacterStream(in.getCharacterStream());
  xin.setEncoding(in.getEncoding());
  return xin;
}
 
开发者ID:relaxng,项目名称:jing-trang,代码行数:8,代码来源:SchemaReaderImpl.java

示例5: parse

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/** Parses a document fragment. */
public void parse(InputSource source, DocumentFragment fragment) 
    throws SAXException, IOException {

    fCurrentNode = fDocumentFragment = fragment;
    fDocument = fDocumentFragment.getOwnerDocument();

    try {
        String pubid = source.getPublicId();
        String sysid = source.getSystemId();
        String encoding = source.getEncoding();
        InputStream stream = source.getByteStream();
        Reader reader = source.getCharacterStream();
        
        XMLInputSource inputSource = 
            new XMLInputSource(pubid, sysid, sysid);
        inputSource.setEncoding(encoding);
        inputSource.setByteStream(stream);
        inputSource.setCharacterStream(reader);
        
        fParserConfiguration.parse(inputSource);
    }
    catch (XMLParseException e) {
        Exception ex = e.getException();
        if (ex != null) {
            throw new SAXParseException(e.getMessage(), null, ex);
        }
        throw new SAXParseException(e.getMessage(), null);
    }

}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:32,代码来源:DOMFragmentParser.java

示例6: parseHtmlImpl

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
 * Parse HTML source.
 *
 * @return a document handler containing the parsed source
 */
private DocumentHandler parseHtmlImpl(String source, HTMLConfiguration config,
    NormalizingTagBalancer tagBalancer)
    throws IOException {

  HTMLScanner htmlScanner = new HTMLScanner();
  tagBalancer.setScanner(htmlScanner);

  DocumentHandler handler = newDocumentHandler(source);

  NamespaceBinder namespaceBinder = new NamespaceBinder();
  namespaceBinder.setDocumentHandler(handler);
  namespaceBinder.setDocumentSource(tagBalancer);
  namespaceBinder.reset(config);
  tagBalancer.setDocumentHandler(namespaceBinder);

  // Order of filter is Scanner -> OSMLFilter -> Tag Balancer
  tagBalancer.setDocumentSource(htmlScanner);
  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;
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:35,代码来源:NekoSimplifiedHtmlParser.java

示例7: resolveEntity

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier	contains the physical co-ordinates of the resource to be resolved
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {

    // When both pubId and sysId are null, the user's entity resolver
    // can do nothing about it. We'd better not bother calling it.
    // This happens when the resourceIdentifier is a GrammarDescription,
    // which describes a schema grammar of some namespace, but without
    // any schema location hint. -Sg
    String pubId = resourceIdentifier.getPublicId();
    String sysId = resourceIdentifier.getExpandedSystemId();
    if (pubId == null && sysId == null)
        return null;

    // resolve entity using SAX entity resolver
    if (fEntityResolver != null && resourceIdentifier != null) {
        try {
            InputSource inputSource = fEntityResolver.resolveEntity(pubId, sysId);
            if (inputSource != null) {
                String publicId = inputSource.getPublicId();
                String systemId = inputSource.getSystemId();
                String baseSystemId = resourceIdentifier.getBaseSystemId();
                InputStream byteStream = inputSource.getByteStream();
                Reader charStream = inputSource.getCharacterStream();
                String encoding = inputSource.getEncoding();
                XMLInputSource xmlInputSource =
                    new XMLInputSource(publicId, systemId, baseSystemId);
                xmlInputSource.setByteStream(byteStream);
                xmlInputSource.setCharacterStream(charStream);
                xmlInputSource.setEncoding(encoding);
                return xmlInputSource;
            }
        }

        // error resolving entity
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve entity
    return null;

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:58,代码来源:EntityResolverWrapper.java

示例8: resolveEntity

import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier	description of the resource to be revsoved
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {
    // resolve entity using DOM entity resolver
    if (fEntityResolver != null) {
        // For entity resolution the type of the resource would be  XML TYPE
        // DOM L3 LS spec mention only the XML 1.0 recommendation right now
        LSInput inputSource =
            resourceIdentifier == null
                ? fEntityResolver.resolveResource(
                    null,
                    null,
                    null,
                    null,
                    null)
                : fEntityResolver.resolveResource(
                    getType(resourceIdentifier),
                    resourceIdentifier.getNamespace(),
                    resourceIdentifier.getPublicId(),
                    resourceIdentifier.getLiteralSystemId(),
                    resourceIdentifier.getBaseSystemId());
        if (inputSource != null) {
            String publicId = inputSource.getPublicId();
            String systemId = inputSource.getSystemId();
            String baseSystemId = inputSource.getBaseURI();
            InputStream byteStream = inputSource.getByteStream();
            Reader charStream = inputSource.getCharacterStream();
            String encoding = inputSource.getEncoding();
            String data = inputSource.getStringData();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId.
             */          
            XMLInputSource xmlInputSource =
                new XMLInputSource(publicId, systemId, baseSystemId);
            
            if (charStream != null) {
                xmlInputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                xmlInputSource.setByteStream((InputStream) byteStream);
            }
            else if (data != null && data.length() != 0) {
                xmlInputSource.setCharacterStream(new StringReader(data));
            }
            xmlInputSource.setEncoding(encoding);
            return xmlInputSource;
        }
    }

    // unable to resolve entity
    return null;

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:65,代码来源:DOMEntityResolverWrapper.java


注:本文中的org.apache.xerces.xni.parser.XMLInputSource.setCharacterStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。