本文整理匯總了Java中javax.xml.transform.stream.StreamSource.getSystemId方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamSource.getSystemId方法的具體用法?Java StreamSource.getSystemId怎麽用?Java StreamSource.getSystemId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.transform.stream.StreamSource
的用法示例。
在下文中一共展示了StreamSource.getSystemId方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: jaxpSourcetoXMLInputSource
import javax.xml.transform.stream.StreamSource; //導入方法依賴的package包/類
XMLInputSource jaxpSourcetoXMLInputSource(Source source){
if(source instanceof StreamSource){
StreamSource stSource = (StreamSource)source;
String systemId = stSource.getSystemId();
String publicId = stSource.getPublicId();
InputStream istream = stSource.getInputStream();
Reader reader = stSource.getReader();
if(istream != null){
return new XMLInputSource(publicId, systemId, null, istream, null);
}
else if(reader != null){
return new XMLInputSource(publicId, systemId,null, reader, null);
}else{
return new XMLInputSource(publicId, systemId, null);
}
}
throw new UnsupportedOperationException("Cannot create " +
"XMLStreamReader or XMLEventReader from a " +
source.getClass().getName());
}
示例2: sourceToInputSource
import javax.xml.transform.stream.StreamSource; //導入方法依賴的package包/類
/**
* Attempt to obtain a SAX InputSource object from a Source
* object.
*
* @param source Must be a non-null Source reference.
*
* @return An InputSource, or null if Source can not be converted.
*/
public static InputSource sourceToInputSource(Source source) {
if (source instanceof SAXSource) {
return ((SAXSource) source).getInputSource();
} else if (source instanceof StreamSource) {
StreamSource ss = (StreamSource) source;
InputSource isource = new InputSource(ss.getSystemId());
isource.setByteStream(ss.getInputStream());
isource.setCharacterStream(ss.getReader());
isource.setPublicId(ss.getPublicId());
return isource;
} else {
return null;
}
}
示例3: jaxpSourcetoXMLInputSource
import javax.xml.transform.stream.StreamSource; //導入方法依賴的package包/類
XMLInputSource jaxpSourcetoXMLInputSource(Source source){
if(source instanceof StreamSource){
StreamSource stSource = (StreamSource)source;
String systemId = stSource.getSystemId();
String publicId = stSource.getPublicId();
InputStream istream = stSource.getInputStream();
Reader reader = stSource.getReader();
if(istream != null){
return new XMLInputSource(publicId, systemId, null, istream, null);
}
else if(reader != null){
return new XMLInputSource(publicId, systemId,null, reader, null);
}else{
return new XMLInputSource(publicId, systemId, null, false);
}
}
throw new UnsupportedOperationException("Cannot create " +
"XMLStreamReader or XMLEventReader from a " +
source.getClass().getName());
}
示例4: toXMLInputSource
import javax.xml.transform.stream.StreamSource; //導入方法依賴的package包/類
/**
* Creates a proper {@link XMLInputSource} from a {@link StreamSource}.
*
* @return always return non-null valid object.
*/
public static final XMLInputSource toXMLInputSource( StreamSource in ) {
if( in.getReader()!=null )
return new XMLInputSource(
in.getPublicId(), in.getSystemId(), in.getSystemId(),
in.getReader(), null );
if( in.getInputStream()!=null )
return new XMLInputSource(
in.getPublicId(), in.getSystemId(), in.getSystemId(),
in.getInputStream(), null );
return new XMLInputSource(
in.getPublicId(), in.getSystemId(), in.getSystemId() );
}
示例5: toXMLInputSource
import javax.xml.transform.stream.StreamSource; //導入方法依賴的package包/類
/**
* Creates a proper {@link XMLInputSource} from a {@link StreamSource}.
*
* @return always return non-null valid object.
*/
public static final XMLInputSource toXMLInputSource( StreamSource in ) {
if( in.getReader()!=null )
return new XMLInputSource(
in.getPublicId(), in.getSystemId(), in.getSystemId(),
in.getReader(), null );
if( in.getInputStream()!=null )
return new XMLInputSource(
in.getPublicId(), in.getSystemId(), in.getSystemId(),
in.getInputStream(), null );
return new XMLInputSource(
in.getPublicId(), in.getSystemId(), in.getSystemId(), false );
}
示例6: getInputStreamFromSource
import javax.xml.transform.stream.StreamSource; //導入方法依賴的package包/類
private InputStream getInputStreamFromSource(StreamSource s)
throws TransformerException {
InputStream stream = s.getInputStream();
if (stream != null)
return stream;
if (s.getReader() != null)
return null;
String systemId = s.getSystemId();
if (systemId != null) {
try {
String fileURL = systemId;
if (systemId.startsWith("file:///"))
{
/*
systemId is:
file:///<drive>:/some/path/file.xml
or
file:///some/path/file.xml
*/
String absolutePath = systemId.substring(7);
/*
/<drive>:/some/path/file.xml
or
/some/path/file.xml
*/
boolean hasDriveDesignator = absolutePath.indexOf(":") > 0;
if (hasDriveDesignator) {
String driveDesignatedPath = absolutePath.substring(1);
/*
<drive>:/some/path/file.xml */
fileURL = driveDesignatedPath;
}
else {
/*
/some/path/file.xml */
fileURL = absolutePath;
}
}
//return new FileInputStream(fileURL);
try {
return new FileInputStream(new File(new URI(fileURL)));
} catch (URISyntaxException ex) {
throw new TransformerException(ex);
}
} catch (IOException e) {
throw new TransformerException(e.toString());
}
}
throw new TransformerException("Unexpected StreamSource object");
}