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


Java Document.createProcessingInstruction方法代码示例

本文整理汇总了Java中org.w3c.dom.Document.createProcessingInstruction方法的典型用法代码示例。如果您正苦于以下问题:Java Document.createProcessingInstruction方法的具体用法?Java Document.createProcessingInstruction怎么用?Java Document.createProcessingInstruction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Document的用法示例。


在下文中一共展示了Document.createProcessingInstruction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createContent

import org.w3c.dom.Document; //导入方法依赖的package包/类
private Document createContent ( final File targetDir, final String type ) throws Exception
{
    final Document doc = createDocument ();

    final ProcessingInstruction pi = doc.createProcessingInstruction ( type, "" );
    pi.setData ( "version=\"1.0.0\"" );
    doc.appendChild ( pi );

    final Element rep = doc.createElement ( "repository" );
    doc.appendChild ( rep );

    final String typeUpper = Character.toUpperCase ( type.charAt ( 0 ) ) + type.substring ( 1 );

    rep.setAttribute ( "name", this.repositoryName );
    rep.setAttribute ( "type", "org.eclipse.equinox.internal.p2.metadata.repository." + typeUpper );
    rep.setAttribute ( "version", "1.0.0" );

    final Element props = doc.createElement ( "properties" );
    rep.appendChild ( props );
    props.setAttribute ( "size", "" + this.properties.size () );

    for ( final Map.Entry<String, String> entry : this.properties.entrySet () )
    {
        addProperty ( props, entry.getKey (), entry.getValue () );
    }

    final Element children = doc.createElement ( "children" );
    rep.appendChild ( children );
    children.setAttribute ( "size", "" + this.dirs.size () );

    for ( final File file : this.dirs )
    {
        final String ref = targetDir.toPath ().relativize ( file.toPath () ).toString ();
        final Element c = doc.createElement ( "child" );
        children.appendChild ( c );
        c.setAttribute ( "location", ref );
    }

    return doc;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:41,代码来源:CompositeBuilder.java

示例2: getAPIDocumentation

import org.w3c.dom.Document; //导入方法依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("/doc")
public Document getAPIDocumentation() throws SAXException, IOException {
	InputStream is = APIDocumentationResource.class.getResourceAsStream("apidoc.xml");
	Document doc = XMLUtils.docBuilder.parse(is);
	Element root = doc.getDocumentElement();
	root.setAttribute("url-base", getURLBase());
	ProcessingInstruction stylesheetPI = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\""+getURLBase()+"/static/style/apidoc2xhtml.xslt\"");
	doc.insertBefore(stylesheetPI, root);
	return doc;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:13,代码来源:APIDocumentationResource.java

示例3: addStylesheet

import org.w3c.dom.Document; //导入方法依赖的package包/类
private void addStylesheet(Document doc) {
	for (Node node : XMLUtils.childrenNodes(doc)) {
		if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
			ProcessingInstruction pi = (ProcessingInstruction) node;
			if (pi.getTarget().equals("xml-stylesheet")) {
				return;
			}
		}
	}
	ProcessingInstruction stylesheetPI = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\""+getURLBase()+"/static/style/alvisnlp-doc2xhtml.xslt\"");
	Element root = doc.getDocumentElement();
	doc.insertBefore(stylesheetPI, root);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:14,代码来源:DocumentableResource.java

示例4: createDOM

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public synchronized org.w3c.dom.Document createDOM(String encodingCharSet) throws EngineException {
	boolean bLog = !(context.requestedObject instanceof Sequence);

	if (bLog) Engine.logContext.trace("[" + getName() + "] creating DOM");
	Document document = XMLUtils.getDefaultDocumentBuilder().newDocument();

	if (bLog) Engine.logContext.trace("XML class: " + document.getClass().getName());

	ProcessingInstruction pi = document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + encodingCharSet + "\"");
	document.appendChild(pi);

	return document;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:15,代码来源:GenericRequester.java

示例5: testPINode

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Test
public void testPINode() {
    try {
        Document xmlDocument = createNewDocument();
        ProcessingInstruction piNode = xmlDocument.createProcessingInstruction("execute", "test");
        String outerXML = getOuterXML(piNode);
        System.out.println("OuterXML of Comment Node is:" + outerXML);

    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Bug6354955.java

示例6: test

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Document document = createDOMWithNS("PITest01.xml");
    ProcessingInstruction pi = document.createProcessingInstruction("PI", "processing");
    assertEquals(pi.getData(), "processing");
    assertEquals(pi.getTarget(), "PI");

    pi.setData("newProcessing");
    assertEquals(pi.getData(), "newProcessing");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:PITest.java

示例7: supplementDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
private void supplementDocument(Document doc) {
	Element root = doc.getDocumentElement();
	root.setAttribute("url-base", getURLBase());
	ProcessingInstruction stylesheetPI = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\""+getURLBase()+"/static/style/alvisnlp-run2xhtml.xslt\"");
	doc.insertBefore(stylesheetPI, root);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:7,代码来源:RunResource.java

示例8: CreateDocumentBeansDoc

import org.w3c.dom.Document; //导入方法依赖的package包/类
public static Document CreateDocumentBeansDoc() throws Exception
{
	// Loggers
	Engine.logBeans = Logger.getLogger(BeansDoc.class);
	Engine.logContext = Logger.getLogger(BeansDoc.class);
	Engine.logEngine = Logger.getLogger(BeansDoc.class);
	
	// Engine properties manager
	EnginePropertiesManager.initProperties();

	// Starting the DBO database exploration...
	Document documentBeansDoc = XMLUtils.getDefaultDocumentBuilder().newDocument();
	ProcessingInstruction pi = documentBeansDoc.createProcessingInstruction("xml",
			"version=\"1.0\" encoding=\"UTF-8\"");
	documentBeansDoc.appendChild(pi);

	Element dbdRoot = documentBeansDoc.createElement("database_objects");
	documentBeansDoc.appendChild(dbdRoot);
	
	DboExplorerManager manager = new DboExplorerManager();
	
	List<DboGroup> groups = manager.getGroups();
	
	for (DboGroup group : groups) {
		Element dbdGroup = documentBeansDoc.createElement("group");
		dbdRoot.appendChild(dbdGroup);	
		Element dbdGroupName = documentBeansDoc.createElement("name");
		Text groupName = documentBeansDoc.createTextNode(group.getName());
		dbdGroupName.appendChild(groupName);
		dbdGroup.appendChild(dbdGroupName);
		List<DboCategory> categories = group.getCategories();
		for (DboCategory category : categories) {
			String categoryName = category.getName();
			Element dbdCategory = documentBeansDoc.createElement("category");
			dbdGroup.appendChild(dbdCategory);	
			Element dbdCategoryName = documentBeansDoc.createElement("name");
			if (!"".equals(categoryName)) {
				dbdCategoryName.appendChild(documentBeansDoc.createTextNode(categoryName));
				dbdCategory.appendChild(dbdCategoryName);
			}
			List<DboBeans> beansCategories = category.getBeans(); 
			for (DboBeans beansCategory : beansCategories) {
				String beansCategoryName = beansCategory.getName();
				Element dbdBeans = documentBeansDoc.createElement("beans");
				dbdCategory.appendChild(dbdBeans);	
				Element dbdBeansName = documentBeansDoc.createElement("name");
				if( !"".equals(beansCategoryName)) {
					Text beansName = documentBeansDoc.createTextNode(beansCategoryName);
					dbdBeansName.appendChild(beansName);
					dbdBeans.appendChild(dbdBeansName);
				}
				List<DboBean> beans = beansCategory.getBeans();
				for (DboBean bean : beans) {
					if(bean.isEnable()) {
						switch (bean.getDocumentedMode()) {
						case TRUE:
							createBeanElement(bean, documentBeansDoc, dbdBeans, true);
							break;
						case FALSE:
							createBeanElement(bean, documentBeansDoc, dbdBeans, false);
							break;
						default: break;
						}
					}
				}
			}
		}
	}
	handleMobileComponents(documentBeansDoc);
	return documentBeansDoc;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:72,代码来源:BeansDoc.java

示例9: testCanonicalForm001

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the doc contains two subsequent processing
 * instrictions, <br>
 * <b>name</b>: canonical-form <br>
 * <b>value</b>: true. <br>
 * <b>Expected results</b>: the subsequent processing instrictions are
 * separated with a single line break
 */
@Test
public void testCanonicalForm001() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    DOMConfiguration config = doc.getDomConfig();

    Element root = doc.getDocumentElement();
    ProcessingInstruction pi1 = doc.createProcessingInstruction("target1", "data1");
    ProcessingInstruction pi2 = doc.createProcessingInstruction("target2", "data2");

    root.appendChild(pi1);
    root.appendChild(pi2);

    if (!config.canSetParameter("canonical-form", Boolean.TRUE)) {
        System.out.println("OK, setting 'canonical-form' to true is not supported");
        return;
    }

    config.setParameter("canonical-form", Boolean.TRUE);
    setHandler(doc);
    doc.normalizeDocument();

    Node child1 = root.getFirstChild();
    Node child2 = child1.getNextSibling();

    if (child2.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
        Assert.fail("the second child is expected to be a" + "single line break, returned: " + child2);
    }

    // return Status.passed("OK");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:DOMConfigurationTest.java

示例10: createDOM

import org.w3c.dom.Document; //导入方法依赖的package包/类
public Document createDOM(String encodingCharSet) {
	Engine.logBeans.debug("(CicsTransaction) XalanServlet: creating DOM");

	Document document = XMLUtils.getDefaultDocumentBuilder().newDocument();
       
	Engine.logBeans.debug("(CicsTransaction) XML class: " + document.getClass().getName());

	ProcessingInstruction pi = document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + encodingCharSet + "\"");
	document.appendChild(pi);

	return document;

}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:14,代码来源:CicsTransaction.java

示例11: createDOM

import org.w3c.dom.Document; //导入方法依赖的package包/类
static public Document createDOM(String encodingCharSet) {
	Engine.logBeans.debug("(SqlTransaction) XalanServlet: creating DOM");

	Document document = XMLUtils.getDefaultDocumentBuilder().newDocument();
       
	Engine.logBeans.debug("(SqlTransaction) XML class: " + document.getClass().getName());

	ProcessingInstruction pi = document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + encodingCharSet + "\"");
	document.appendChild(pi);

	return document;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:13,代码来源:SqlTransaction.java


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