Refine search
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; } }
/** * Pushes an input source onto the current entity stack. This enables the scanner to * transparently scan new content (e.g. the output written by an embedded script). At the end of * the current entity, the scanner returns where it left off at the time this entity source was * pushed. * <p> * <strong>Note:</strong> This functionality is experimental at this time and is subject to * change in future releases of NekoHTML. * * @param inputSource The new input source to start scanning. * @see #evaluateInputSource(XMLInputSource) */ public void pushInputSource(XMLInputSource inputSource) { final Reader reader = getReader(inputSource); fCurrentEntityStack.push(fCurrentEntity); String encoding = inputSource.getEncoding(); String publicId = inputSource.getPublicId(); String baseSystemId = inputSource.getBaseSystemId(); String literalSystemId = inputSource.getSystemId(); String expandedSystemId = expandSystemId(literalSystemId, baseSystemId); fCurrentEntity = new CurrentEntity(reader, encoding, publicId, baseSystemId, literalSystemId, expandedSystemId); } // pushInputSource(XMLInputSource)
private Reader getReader(final XMLInputSource inputSource) { Reader reader = inputSource.getCharacterStream(); if (reader == null) { try { return new InputStreamReader(inputSource.getByteStream(), fJavaEncoding); } catch (final UnsupportedEncodingException e) { // should not happen as this encoding is already used to parse the "main" source } } return reader; }
public XMLDTDDescription(XMLInputSource source) { this.setValues(source.getPublicId(), null, source.getBaseSystemId(), source.getSystemId()); this.fRootName = null; this.fPossibleRoots = null; } // init(XMLInputSource)
private XMLInputSource newInputSource( String replacementText ) { StringBuffer systemID = new StringBuffer( _systemID ); systemID.append( "script" ).append( ++_scriptIndex ); return new XMLInputSource( null, systemID.toString(), null, new StringReader( replacementText ), "UTF-8" ); }
@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); } }
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; } } }
is = new XMLInputSource(publicId, referringSchemaInputSource.getSystemId() + INLINE_SCHEMA_ID, null, new StringReader(schema),null);
public LSInput resolveResource(String type,String ns, String publicId, String systemId, String baseUri) { if(fEntityResolver==null) return null; try { XMLInputSource is = fEntityResolver.resolveEntity( new XMLResourceIdentifierImpl(publicId,systemId,baseUri,null)); if(is==null) return null; LSInput di = new DOMInputImpl(); di.setBaseURI(is.getBaseSystemId()); di.setByteStream(is.getByteStream()); di.setCharacterStream(is.getCharacterStream()); di.setEncoding(is.getEncoding()); di.setPublicId(is.getPublicId()); di.setSystemId(is.getSystemId()); return di; } catch( IOException e ) { // erors thrown by the callback is not supposed to be // reported to users. throw new XNIException(e); } } });
@Override public XMLInputSource resolveEntity(XMLResourceIdentifier id) throws XNIException, IOException { String systemId = id.getLiteralSystemId(); debug("Resolving " + systemId); XMLInputSource source = new XMLInputSource(id); source.setByteStream(resolver.getStream(systemId)); return source; } }
private static XMLEntityResolver getXmlEntityResolver(String encoding) { return new XMLEntityResolver() { public XMLInputSource resolveEntity(XMLResourceIdentifier arg) throws XNIException, IOException { URL url = new URL(arg.getExpandedSystemId()); return new XMLInputSource(arg.getPublicId(), arg.getExpandedSystemId(), arg.getExpandedSystemId(), url.openStream(), "UTF-8"); } }; } }
filtersVector.copyInto(filters); parser.setProperty(FILTERS, filters); XMLInputSource source = new XMLInputSource(null, arg, null); source.setEncoding(iencoding); parser.parse(source);
!(includedSource instanceof HTTPInputSource) && (accept != null || acceptLanguage != null) && includedSource.getCharacterStream() == null && includedSource.getByteStream() == null) { includedSource = createInputSource(includedSource.getPublicId(), includedSource.getSystemId(), includedSource.getBaseSystemId(), accept, acceptLanguage); includedSource = new XMLInputSource(null, href, fCurrentBaseURI.getExpandedSystemId()); includedSource.setEncoding(encoding); XIncludeTextReader textReader = null;
final StreamSource streamSource = (StreamSource) source; final StreamResult streamResult = (StreamResult) result; XMLInputSource input = new XMLInputSource(streamSource.getPublicId(), streamSource.getSystemId(), null); input.setByteStream(streamSource.getInputStream()); input.setCharacterStream(streamSource.getReader());
/** * Sets the byte stream. If the byte stream is not already opened * when this object is instantiated, then the code that opens the * stream should also set the byte stream on this object. Also, if * the encoding is auto-detected, then the encoding should also be * set on this object. * * @param byteStream The new byte stream. */ public void setByteStream(InputStream byteStream) { super.setByteStream(byteStream); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setByteStream(byteStream); } // setByteStream(InputStream)
fDoctypePublicId = src.getPublicId(); fDoctypeSystemId = src.getSystemId();
XSDDescription desc = new XSDDescription(); desc.fContextType = XSDDescription.CONTEXT_PREPARSE; desc.setBaseSystemId(source.getBaseSystemId()); desc.setLiteralSystemId( source.getSystemId());
/** * Sets the encoding of the stream. * * @param encoding The new encoding. */ public void setEncoding(String encoding) { super.setEncoding(encoding); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setEncoding(encoding); } // setEncoding(String)
/** * Sets the character stream. If the character stream is not already * opened when this object is instantiated, then the code that opens * the stream should also set the character stream on this object. * Also, the encoding of the byte stream used by the reader should * also be set on this object, if known. * * @param charStream The new character stream. * * @see #setEncoding */ public void setCharacterStream(Reader charStream) { super.setCharacterStream(charStream); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setCharacterStream(charStream); } // setCharacterStream(Reader)
/** * Error handling code shared between the various getSchemaDocument() methods. */ private Element getSchemaDocument1(boolean mustResolve, boolean hasInput, XMLInputSource schemaSource, Element referElement, IOException ioe) { // either an error occured (exception), or empty input source was // returned, we need to report an error or a warning if (mustResolve) { if (hasInput) { reportSchemaError("schema_reference.4", new Object[]{schemaSource.getSystemId()}, referElement, ioe); } else { reportSchemaError("schema_reference.4", new Object[]{schemaSource == null ? "" : schemaSource.getSystemId()}, referElement, ioe); } } else if (hasInput) { reportSchemaWarning("schema_reference.4", new Object[]{schemaSource.getSystemId()}, referElement, ioe); } fLastSchemaWasDuplicate = false; return null; } // getSchemaDocument1(boolean, boolean, XMLInputSource, Element): Element