本文整理汇总了Java中org.w3c.dom.DOMImplementation类的典型用法代码示例。如果您正苦于以下问题:Java DOMImplementation类的具体用法?Java DOMImplementation怎么用?Java DOMImplementation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DOMImplementation类属于org.w3c.dom包,在下文中一共展示了DOMImplementation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveDocumentTo
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
private void saveDocumentTo() throws XMLException {
try {
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer transf = tfactory.newTransformer();
transf.setOutputProperty( OutputKeys.INDENT, "yes" );
transf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transf.setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "no" );
transf.setOutputProperty( OutputKeys.METHOD, "xml" );
DOMImplementation impl = doc.getImplementation();
DocumentType doctype = impl.createDocumentType( "doctype",
"-//Recordare//DTD MusicXML 3.0 Partwise//EN", "http://www.musicxml.org/dtds/partwise.dtd" );
transf.setOutputProperty( OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId() );
transf.setOutputProperty( OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId() );
DOMSource src = new DOMSource( doc );
StreamResult resultS = new StreamResult( file );
transf.transform( src, resultS );
} catch ( TransformerException e ) {
throw new XMLException( "Could not save the File" );
}
}
示例2: getDocumentType
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
private static DocumentType getDocumentType(Document doc) {
DOMImplementation domImpl = doc.getImplementation();
// <!DOCTYPE datafile PUBLIC "-//Logiqx//DTD ROM Management Datafile//EN" "http://www.logiqx.com/Dats/datafile.dtd">
DocumentType doctype = domImpl.createDocumentType("datafile",
"-//Logiqx//DTD ROM Management Datafile//EN",
"http://www.logiqx.com/Dats/datafile.dtd");
return doctype;
}
示例3: getDOMImplementation
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* Obtains DOMImpementaton interface providing a number of methods for performing
* operations that are independent of any particular DOM instance.
*
* @throw DOMException <code>NOT_SUPPORTED_ERR</code> if cannot get DOMImplementation
* @throw FactoryConfigurationError Application developers should never need to directly catch errors of this type.
*
* @return DOMImplementation implementation
*/
private static DOMImplementation getDOMImplementation()
throws DOMException { //can be made public
DocumentBuilderFactory factory = getFactory(false, false);
try {
return factory.newDocumentBuilder().getDOMImplementation();
} catch (ParserConfigurationException ex) {
throw new DOMException(
DOMException.NOT_SUPPORTED_ERR, "Cannot create parser satisfying configuration parameters"
); //NOI18N
} catch (RuntimeException e) {
// E.g. #36578, IllegalArgumentException. Try to recover gracefully.
throw (DOMException) new DOMException(DOMException.NOT_SUPPORTED_ERR, e.toString()).initCause(e);
}
}
示例4: getDOMImplementation
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* @return with which to create document instances.
* @throws java.sql.SQLException when unable to obtain the DOM
* implementation instance.
*/
protected static DOMImplementation getDOMImplementation() throws SQLException {
if (domImplementation == null) {
domImplementation =
getDOMImplementationRegistry().getDOMImplementation(
domFeatures);
}
if (domImplementation == null) {
Exception ex = new RuntimeException("Not supported: "
+ domFeatures);
throw Exceptions.domInstantiation(ex);
}
return domImplementation;
}
示例5: writeSVG
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
private void writeSVG(OutputStream stream) throws IOException {
DOMImplementation impl = GenericDOMImplementation
.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
Document myFactory = impl.createDocument(svgNS, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory);
ctx.setEmbeddedFontsOn(Options.getBoolean("EMBEDDED_SVG_FONTS", true));
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, Options.getBoolean(
"EMBEDDED_SVG_FONTS", true));
svgGenerator.setSVGCanvasSize(size);
paint(svgGenerator, 0, 0);
boolean useCSS = true;
Writer out = new OutputStreamWriter(stream, "UTF-8");
svgGenerator.stream(out, useCSS);
}
示例6: getDOMImplementationList
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* Return a list of implementations that support the
* desired features.
*
* @param features
* A string that specifies which features are required. This is
* a space separated list in which each feature is specified by
* its name optionally followed by a space and a version number.
* This is something like: "XML 1.0 Traversal +Events 2.0"
* @return A list of DOMImplementations that support the desired features.
*/
public DOMImplementationList getDOMImplementationList(final String features) {
final Vector implementations = new Vector();
int size = sources.size();
for (int i = 0; i < size; i++) {
DOMImplementationSource source =
(DOMImplementationSource) sources.elementAt(i);
DOMImplementationList impls =
source.getDOMImplementationList(features);
for (int j = 0; j < impls.getLength(); j++) {
DOMImplementation impl = impls.item(j);
implementations.addElement(impl);
}
}
return new DOMImplementationList() {
public DOMImplementation item(final int index) {
if (index >= 0 && index < implementations.size()) {
try {
return (DOMImplementation)
implementations.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
}
return null;
}
public int getLength() {
return implementations.size();
}
};
}
示例7: getDOMImplementation
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* A method to request a DOM implementation.
* @param features A string that specifies which features are required.
* This is a space separated list in which each feature is specified
* by its name optionally followed by a space and a version number.
* This is something like: "XML 1.0 Traversal Events 2.0"
* @return An implementation that has the desired features, or
* <code>null</code> if this source has none.
*/
public DOMImplementation getDOMImplementation(String features) {
// first check whether the CoreDOMImplementation would do
DOMImplementation impl =
CoreDOMImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
return impl;
}
// if not try the DOMImplementation
impl = DOMImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
return impl;
}
return null;
}
示例8: getDOMImplementation
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* A method to request a DOM implementation.
* @param features A string that specifies which features are required.
* This is a space separated list in which each feature is specified
* by its name optionally followed by a space and a version number.
* This is something like: "XML 1.0 Traversal Events 2.0"
* @return An implementation that has the desired features, or
* <code>null</code> if this source has none.
*/
public DOMImplementation getDOMImplementation(String features) {
DOMImplementation impl = super.getDOMImplementation(features);
if (impl != null){
return impl;
}
// if not try the PSVIDOMImplementation
impl = PSVIDOMImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
return impl;
}
// if not try the XSImplementation
impl = XSImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
return impl;
}
return null;
}
示例9: getDOMImplementationList
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* A method to request a list of DOM implementations that support the
* specified features and versions, as specified in .
* @param features A string that specifies which features and versions
* are required. This is a space separated list in which each feature
* is specified by its name optionally followed by a space and a
* version number. This is something like: "XML 3.0 Traversal +Events
* 2.0"
* @return A list of DOM implementations that support the desired
* features.
*/
public DOMImplementationList getDOMImplementationList(String features) {
final Vector implementations = new Vector();
// first check whether the CoreDOMImplementation would do
DOMImplementationList list = super.getDOMImplementationList(features);
//Add core DOMImplementations
for (int i=0; i < list.getLength(); i++ ) {
implementations.addElement(list.item(i));
}
DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
implementations.addElement(impl);
}
impl = XSImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
implementations.addElement(impl);
}
return new DOMImplementationListImpl(implementations);
}
示例10: main
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
String format = "javax_imageio_1.0";
BufferedImage img =
new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
IIOMetadata meta =
iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
DOMImplementationRegistry registry;
registry = DOMImplementationRegistry.newInstance();
DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
Document doc = impl.createDocument(null, format, null);
Element root, text, entry;
root = doc.getDocumentElement();
root.appendChild(text = doc.createElement("Text"));
text.appendChild(entry = doc.createElement("TextEntry"));
// keyword isn't #REQUIRED by the standard metadata format.
// However, it is required by the PNG format, so we include it here.
entry.setAttribute("keyword", "Comment");
entry.setAttribute("value", "Some demo comment");
meta.mergeTree(format, root);
}
示例11: main
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
DOMImplementation impl = document.getImplementation();
DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0");
LSSerializer dsi = implLS.createLSSerializer();
/* We should have here incorrect document without getXmlVersion() method:
* Such Document is generated by replacing the JDK bootclasses with it's
* own Node,Document and DocumentImpl classes (see run.sh). According to
* XERCESJ-1007 the AbstractMethodError should be thrown in such case.
*/
String result = dsi.writeToString(document);
System.out.println("Result:" + result);
}
示例12: getFeatureSupportedList
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
@DataProvider(name = "feature-supported")
public Object[][] getFeatureSupportedList() throws ParserConfigurationException {
DOMImplementation impl = getDOMImplementation();
return new Object[][] {
{ impl, "XML", "2.0", true },
{ impl, "HTML", "2.0", false },
{ impl, "Views", "2.0", false },
{ impl, "StyleSheets", "2.0", false },
{ impl, "CSS", "2.0", false },
{ impl, "CSS2", "2.0", false },
{ impl, "Events", "2.0", true },
{ impl, "UIEvents", "2.0", false },
{ impl, "MouseEvents", "2.0", false },
{ impl, "HTMLEvents", "2.0", false },
{ impl, "Traversal", "2.0", true },
{ impl, "Range", "2.0", true },
{ impl, "Core", "2.0", true },
{ impl, "XML", "", true } };
}
示例13: canvasInit
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
public boolean canvasInit(JSVGCanvas canvas) {
DOMImplementation impl =
GenericDOMImplementation.getDOMImplementation();
Document doc = impl.createDocument(SVGConstants.SVG_NAMESPACE_URI,
SVGConstants.SVG_SVG_TAG, null);
Element e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI,
SVGConstants.SVG_RECT_TAG);
e.setAttribute("x", "10");
e.setAttribute("y", "10");
e.setAttribute("width", "100");
e.setAttribute("height", "50");
e.setAttribute("fill", "crimson");
doc.getDocumentElement().appendChild(e);
e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI,
SVGConstants.SVG_CIRCLE_TAG);
e.setAttribute("cx", "55");
e.setAttribute("cy", "35");
e.setAttribute("r", "30");
e.setAttribute("fill", "gold");
doc.getDocumentElement().appendChild(e);
canvas.setDocument(doc);
return false; // We didn't trigger a load event.
}
示例14: write
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
public org.w3c.dom.Document write(Document document, org.w3c.dom.DOMImplementation domImpl)
throws DocumentException
{
if (document instanceof org.w3c.dom.Document)
{
return (org.w3c.dom.Document)document;
}
resetNamespaceStack();
org.w3c.dom.Document domDocument = createDomDocument(document, domImpl);
appendDOMTree(domDocument, domDocument, document.content());
namespaceStack.clear();
return domDocument;
}
示例15: getImplementations
import org.w3c.dom.DOMImplementation; //导入依赖的package包/类
/**
* Returns a list of the implementations that support the specified
* features.
*/
private final List getImplementations(String features)
{
List available = new ArrayList(Arrays.asList(implementations));
for (Iterator i = parseFeatures(features).iterator(); i.hasNext(); )
{
String feature = (String) i.next();
String version = null;
int si = feature.indexOf(' ');
if (si != -1)
{
version = feature.substring(si + 1);
feature = feature.substring(0, si);
}
for (Iterator j = available.iterator(); j.hasNext(); )
{
DOMImplementation impl = (DOMImplementation) j.next();
if (!impl.hasFeature(feature, version))
{
j.remove();
}
}
}
return available;
}