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


Java DOMImplementation类代码示例

本文整理汇总了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" );
	}
}
 
开发者ID:Paulpanther,项目名称:Random-Music-Generator,代码行数:26,代码来源:XMLGenerator.java

示例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;
}
 
开发者ID:phweda,项目名称:MFM,代码行数:9,代码来源:PersistUtils.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:XMLUtil.java

示例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;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:23,代码来源:JDBCSQLXML.java

示例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);

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:21,代码来源:PIDEF0painter.java

示例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();
            }
        };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:DOMImplementationRegistry.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:DOMImplementationSourceImpl.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:DOMXSImplementationSourceImpl.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:DOMXSImplementationSourceImpl.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:MergeStdCommentTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AbstractMethodErrorTest.java

示例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 } };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:DomImplementationTest.java

示例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.
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:26,代码来源:SetSVGDocumentTest.java

示例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;
}
 
开发者ID:iOffice1,项目名称:iOffice,代码行数:17,代码来源:DOMWriter.java

示例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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:ImplementationSource.java


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