本文整理汇总了Java中org.w3c.dom.DocumentType.getSystemId方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentType.getSystemId方法的具体用法?Java DocumentType.getSystemId怎么用?Java DocumentType.getSystemId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.DocumentType
的用法示例。
在下文中一共展示了DocumentType.getSystemId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* Write.
*
* @param node
* the node
* @throws ShellException
* the shell exception
*/
protected void write(DocumentType node) throws ShellException {
printWriter.print("<!DOCTYPE "); //$NON-NLS-1$
printWriter.print(node.getName());
String publicId = node.getPublicId();
String systemId = node.getSystemId();
if (publicId != null) {
printWriter.print(" PUBLIC \""); //$NON-NLS-1$
printWriter.print(publicId);
printWriter.print("\" \""); //$NON-NLS-1$
printWriter.print(systemId);
printWriter.print('\"');
} else if (systemId != null) {
printWriter.print(" SYSTEM \""); //$NON-NLS-1$
printWriter.print(systemId);
printWriter.print('"');
}
String internalSubset = node.getInternalSubset();
if (internalSubset != null) {
printWriter.println(" ["); //$NON-NLS-1$
printWriter.print(internalSubset);
printWriter.print(']');
}
printWriter.println('>');
}
示例2: write
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
protected void write(DocumentType node) throws ShellException {
printWriter.print("<!DOCTYPE "); //$NON-NLS-1$
printWriter.print(node.getName());
String publicId = node.getPublicId();
String systemId = node.getSystemId();
if (publicId != null) {
printWriter.print(" PUBLIC \""); //$NON-NLS-1$
printWriter.print(publicId);
printWriter.print("\" \""); //$NON-NLS-1$
printWriter.print(systemId);
printWriter.print('\"');
} else if (systemId != null) {
printWriter.print(" SYSTEM \""); //$NON-NLS-1$
printWriter.print(systemId);
printWriter.print('"');
}
String internalSubset = node.getInternalSubset();
if (internalSubset != null) {
printWriter.println(" ["); //$NON-NLS-1$
printWriter.print(internalSubset);
printWriter.print(']');
}
printWriter.println('>');
}
示例3: whichDoctypeSystem
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* Returns the document type system identifier
* specified for this document, or null.
*/
public static String whichDoctypeSystem( Document doc )
{
DocumentType doctype;
/* DOM Level 2 was introduced into the code base*/
doctype = doc.getDoctype();
if ( doctype != null ) {
// Note on catch: DOM Level 1 does not specify this method
// and the code will throw a NoSuchMethodError
try {
return doctype.getSystemId();
} catch ( Error except ) { }
}
if ( doc instanceof HTMLDocument )
return DTD.XHTMLSystemId;
return null;
}
示例4: getDocumentTypeDeclarationSystemIdentifier
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* A document type declaration information item has the following properties:
*
* 1. [system identifier] The system identifier of the external subset, if
* it exists. Otherwise this property has no value.
*
* @return the system identifier String object, or null if there is none.
*/
public String getDocumentTypeDeclarationSystemIdentifier()
{
Document doc;
if (m_root.getNodeType() == Node.DOCUMENT_NODE)
doc = (Document) m_root;
else
doc = m_root.getOwnerDocument();
if (null != doc)
{
DocumentType dtd = doc.getDoctype();
if (null != dtd)
{
return dtd.getSystemId();
}
}
return null;
}
示例5: write
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
protected void write(DocumentType node) throws ShellException {
printWriter.print("<!DOCTYPE "); //$NON-NLS-1$
printWriter.print(node.getName());
String publicId = node.getPublicId();
String systemId = node.getSystemId();
if (publicId != null) {
printWriter.print(" PUBLIC \""); //$NON-NLS-1$
printWriter.print(publicId);
printWriter.print("\" \""); //$NON-NLS-1$
printWriter.print(systemId);
printWriter.print('\"');
} else if (systemId != null) {
printWriter.print(" SYSTEM \""); //$NON-NLS-1$
printWriter.print(systemId);
printWriter.print('"');
}
String internalSubset = node.getInternalSubset();
if (internalSubset != null) {
printWriter.println(" ["); //$NON-NLS-1$
printWriter.print(internalSubset);
printWriter.print(']');
}
printWriter.println('>');
}
示例6: write
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @since TFP 1.0
*/
public void write (final Document document)
{
DocumentType doctype = document.getDoctype ();
output.print ("<?xml version=\"1.0\" encoding=\"" + getEncoding () + "\"?>");
if (doctype != null) {
output.print ("<!DOCTYPE " + doctype.getName ());
if (doctype.getPublicId () != null) {
output.print (" PUBLIC \"" + doctype.getPublicId () + "\"");
output.print (" \"" + doctype.getSystemId () +"\"");
}
else if (doctype.getSystemId () != null)
output.print (" SYSTEM \"" + doctype.getSystemId () + "\"");
if (doctype.getInternalSubset () != null) {
output.print (" [");
output.print (doctype.getInternalSubset ());
}
output.print (">");
}
write (document.getDocumentElement ());
}
示例7: write
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @since TFP 1.0
*/
public void write (Document document)
{
DocumentType doctype = document.getDoctype ();
output.println ("<?xml version=\"1.0\" encoding=\"" + getEncoding () + "\"?>");
if (doctype != null) {
output.print ("<!DOCTYPE " + doctype.getName ());
if (doctype.getPublicId () != null) {
output.print (" PUBLIC \"" + doctype.getPublicId () + "\"");
output.print (" \"" + doctype.getSystemId () +"\"");
}
else if (doctype.getSystemId () != null)
output.print (" SYSTEM \"" + doctype.getSystemId () + "\"");
if (doctype.getInternalSubset () != null) {
output.println (" [");
output.println (doctype.getInternalSubset ());
output.print ("]");
}
output.println (">");
}
write (document.getDocumentElement ());
}
示例8: write
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* Writes a DOM document to a stream.
* The precise output format is not guaranteed but this method will attempt to indent it sensibly.
*
* <p class="nonnormative"><b>Important</b>: There might be some problems with
* <code><![CDATA[ ]]></code> sections in the DOM tree you pass into this method. Specifically,
* some CDATA sections my not be written as CDATA section or may be merged with
* other CDATA section at the same level. Also if plain text nodes are mixed with
* CDATA sections at the same level all text is likely to end up in one big CDATA section.
* <br/>
* For nodes that only have one CDATA section this method should work fine.
* </p>
*
* @param doc DOM document to be written
* @param out data sink
* @param enc XML-defined encoding name (e.g. "UTF-8")
* @throws IOException if JAXP fails or the stream cannot be written to
*/
public static void write(Document doc, OutputStream out, String enc) throws IOException {
if (enc == null) {
throw new NullPointerException("You must set an encoding; use \"UTF-8\" unless you have a good reason not to!"); // NOI18N
}
Document doc2 = normalize(doc);
ClassLoader orig = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { // #195921
@Override public ClassLoader run() {
return new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
@Override public InputStream getResourceAsStream(String name) {
if (name.startsWith("META-INF/services/")) {
return new ByteArrayInputStream(new byte[0]); // JAXP #6723276
}
return super.getResourceAsStream(name);
}
};
}
}));
try {
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(
new StreamSource(new StringReader(IDENTITY_XSLT_WITH_INDENT)));
DocumentType dt = doc2.getDoctype();
if (dt != null) {
String pub = dt.getPublicId();
if (pub != null) {
t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, pub);
}
String sys = dt.getSystemId();
if (sys != null) {
t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, sys);
}
}
t.setOutputProperty(OutputKeys.ENCODING, enc);
try {
t.setOutputProperty(ORACLE_IS_STANDALONE, "yes");
} catch (IllegalArgumentException x) {
// fine, introduced in JDK 7u4
}
// See #123816
Set<String> cdataQNames = new HashSet<String>();
collectCDATASections(doc2, cdataQNames);
if (cdataQNames.size() > 0) {
StringBuilder cdataSections = new StringBuilder();
for(String s : cdataQNames) {
cdataSections.append(s).append(' '); //NOI18N
}
t.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, cdataSections.toString());
}
Source source = new DOMSource(doc2);
Result result = new StreamResult(out);
t.transform(source, result);
} catch (Exception e) {
throw new IOException(e);
} finally {
Thread.currentThread().setContextClassLoader(orig);
}
}
示例9: serializeDocType
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* Serializes a Document Type Node.
*
* @param node The Docuemnt Type Node to serialize
* @param bStart Invoked at the start or end of node. Default true.
*/
protected void serializeDocType(DocumentType node, boolean bStart)
throws SAXException {
// The DocType and internalSubset can not be modified in DOM and is
// considered to be well-formed as the outcome of successful parsing.
String docTypeName = node.getNodeName();
String publicId = node.getPublicId();
String systemId = node.getSystemId();
String internalSubset = node.getInternalSubset();
//DocumentType nodes are never passed to the filter
if (internalSubset != null && !"".equals(internalSubset)) {
if (bStart) {
try {
// The Serializer does not provide a way to write out the
// DOCTYPE internal subset via an event call, so we write it
// out here.
Writer writer = fSerializer.getWriter();
StringBuffer dtd = new StringBuffer();
dtd.append("<!DOCTYPE ");
dtd.append(docTypeName);
if (null != publicId) {
dtd.append(" PUBLIC \"");
dtd.append(publicId);
dtd.append('\"');
}
if (null != systemId) {
if (null == publicId) {
dtd.append(" SYSTEM \"");
} else {
dtd.append(" \"");
}
dtd.append(systemId);
dtd.append('\"');
}
dtd.append(" [ ");
dtd.append(fNewLine);
dtd.append(internalSubset);
dtd.append("]>");
dtd.append(fNewLine);
writer.write(dtd.toString());
writer.flush();
} catch (IOException e) {
throw new SAXException(Utils.messages.createMessage(
MsgKey.ER_WRITING_INTERNAL_SUBSET, null), e);
}
} // else if !bStart do nothing
} else {
if (bStart) {
if (fLexicalHandler != null) {
fLexicalHandler.startDTD(docTypeName, publicId, systemId);
}
} else {
if (fLexicalHandler != null) {
fLexicalHandler.endDTD();
}
}
}
}
示例10: createTransformer
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/**
* Creates a new JAXP Transformer object that will be used to serialize this
* DOM. This method may be overridden in order to set custom properties on
* the Transformer.
*
* @return The transformer to be used for serialization.
*/
protected javax.xml.transform.Transformer createTransformer()
throws IOException {
try {
javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory
.newInstance().newTransformer();
transformer.setOutputProperty(
javax.xml.transform.OutputKeys.METHOD, "xml");
transformer.setOutputProperty(
javax.xml.transform.OutputKeys.INDENT,
isIndenting() ? "yes" : "no");
if (getCharacterSet() != null) {
transformer.setOutputProperty(
javax.xml.transform.OutputKeys.ENCODING,
getCharacterSet().getName());
} else {
transformer.setOutputProperty(
javax.xml.transform.OutputKeys.ENCODING,
CharacterSet.ISO_8859_1.getName());
}
DocumentType docType = getDocument().getDoctype();
if (docType != null) {
if (docType.getSystemId() != null) {
transformer.setOutputProperty(
javax.xml.transform.OutputKeys.DOCTYPE_SYSTEM,
getDocument().getDoctype().getSystemId());
}
if (docType.getPublicId() != null) {
transformer.setOutputProperty(
javax.xml.transform.OutputKeys.DOCTYPE_PUBLIC,
getDocument().getDoctype().getPublicId());
}
}
return transformer;
} catch (javax.xml.transform.TransformerConfigurationException tce) {
throw new IOException("Couldn't write the XML representation: "
+ tce.getMessage());
}
}
示例11: getAccelerator
import org.w3c.dom.DocumentType; //导入方法依赖的package包/类
/** Parse the accelerator from the optics URL with the specified DTD validation flag */
public Accelerator getAccelerator( final boolean isValidating ) throws XmlDataAdaptor.ParseException {
String absoluteUrlSpec = absoluteUrlSpec( opticsUrlSpec );
XmlDataAdaptor adaptor = XmlDataAdaptor.adaptorForUrl( absoluteUrlSpec, isValidating, xdxfSchema );
Document document = adaptor.document();
DocumentType docType = document.getDoctype();
if (docType != null) dtdUrlSpec = docType.getSystemId();
DataAdaptor accelAdaptor = adaptor.childAdaptor( acceleratorTag );
Accelerator accelerator = new Accelerator( CHANNEL_FACTORY );
accelerator.setNodeFactory( DEVICE_MANAGER.getNodeFactory() );
accelerator.setElementMapping(elementMapping);
EditContext editContext = tableManager.readEditContext( isValidating );
accelerator.setEditContext( editContext );
accelerator.setTimingCenter( getTimingCenter() );
accelerator.update( accelAdaptor );
loadExtraOptics( accelerator, isValidating );
loadHardwareStatus( accelerator, isValidating );
return accelerator;
}