gpt4 book ai didi

org.codehaus.cargo.util.XmlUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 22:28:40 29 4
gpt4 key购买 nike

本文整理了Java中org.codehaus.cargo.util.XmlUtils类的一些代码示例,展示了XmlUtils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtils类的具体详情如下:
包路径:org.codehaus.cargo.util.XmlUtils
类名称:XmlUtils

XmlUtils介绍

[英]This class offers utility methods for handling XML files.
[中]这个类提供了处理XML文件的实用方法。

代码示例

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-util

/**
 * creates the instance, which will use the specified @{link FileHandler fileHandler} to read or
 * write the xml file.
 *
 * @param fileHandler used for file i/o.
 * @param namespaceAware true if builder should be namespace aware.
 */
public DefaultXmlFileBuilder(FileHandler fileHandler, boolean namespaceAware)
{
  xmlUtil = new XmlUtils(fileHandler, namespaceAware);
}

代码示例来源:origin: codehaus-cargo/cargo

/**
 * {@inheritDoc}
 */
@Override
public void writeFile()
{
  xmlUtil.saveXml(document, path);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-util

/**
 * {@inheritDoc}
 */
@Override
public Document loadFile()
{
  this.document = xmlUtil.loadXmlFromFile(path);
  return this.document;
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

/**
 * {@inheritDoc}
 * 
 * @param container container to configure
 */
public WebLogic9x10x103x12xConfigXmlInstalledLocalDeployer(InstalledLocalContainer container)
{
  super(container);
  xmlTool = new XmlUtils();
  if (container instanceof WebLogic12xInstalledLocalContainer
    || container instanceof WebLogic121xInstalledLocalContainer)
  {
    namespace = "http://xmlns.oracle.com/weblogic/domain";
  }
  else
  {
    namespace = "http://www.bea.com/ns/weblogic/920/domain";
  }
  xmlTool.getNamespaces().put("weblogic", namespace);
  // using the same filehandler as the container will help pass unit tests
  FileHandler handler = container.getFileHandler();
  xmlTool.setFileHandler(handler);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-util

/**
 * {@inheritDoc}
 */
@Override
public void insertElementsUnderXPath(String elementsToParse, String xpath)
{
  Element parent = xmlUtil.selectElementMatchingXPath(xpath, document.getDocumentElement());
  StringBuilder nested = new StringBuilder();
  nested.append("<parent>");
  nested.append(elementsToParse);
  nested.append("</parent>");
  Element nestedElements = xmlUtil.parseIntoElement(nested.toString());
  NodeList children = nestedElements.getChildNodes();
  for (int i = 0; i < children.getLength(); i++)
  {
    Node child = children.item(i);
    Node clone = parent.getOwnerDocument().importNode(child, true);
    parent.appendChild(clone);
  }
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-util

throws CargoException
XmlUtils domUtils = new XmlUtils(this);
Document doc = domUtils.loadXmlFromFile(file);
domUtils.saveXml(doc, file);

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

/**
 * {@inheritDoc} deploys files by adding their configuration to the config.xml file of the
 * WebLogic server.
 */
@Override
public void deploy(Deployable deployable)
{
  XmlUtils xmlUtil = new XmlUtils(getFileHandler());
  Document configXml =
    xmlUtil.loadXmlFromFile(getFileHandler().append(getDomainHome(), "config.xml"));
  Element domain = xmlUtil.selectElementMatchingXPath("//Domain",
    configXml.getDocumentElement());
  if (deployable.getType() == DeployableType.WAR)
  {
    addWarToDomain((WAR) deployable, domain);
  }
  else if (deployable.getType() == DeployableType.EAR)
  {
    addEarToDomain((EAR) deployable, domain);
  }
  else
  {
    throw new ContainerException("Not supported");
  }
  this.writeConfigXml(configXml);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

/**
 * {@inheritDoc} undeploys files by removing their configuration to the config.xml file of the
 * WebLogic server.
 */
@Override
public void undeploy(Deployable deployable)
{
  XmlUtils xmlUtil = new XmlUtils(getFileHandler());
  Document configXml =
    xmlUtil.loadXmlFromFile(getFileHandler().append(getDomainHome(), "config.xml"));
  List<Element> results = xmlUtil.selectElementsMatchingXPath("//Application[@Path='"
    + getFileHandler().getParent(getAbsolutePath(deployable)) + "']",
      configXml.getDocumentElement());
  for (Element element : results)
  {
    configXml.removeChild(element);
  }
  this.writeConfigXml(configXml);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

/**
 * write the domain's config.xml to disk.
 * 
 * @param configXml document to write to disk
 */
public void writeConfigXml(Document configXml)
{
  XmlUtils xmlUtil = new XmlUtils(getFileHandler());
  xmlUtil.saveXml(configXml, getFileHandler().append(getDomainHome(), "config.xml"));
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

/**
 * {@inheritDoc}
 * @see org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfiguration#AbstractStandaloneLocalConfiguration(String)
 */
public WebLogic9xStandaloneLocalConfiguration(String dir)
{
  super(dir);
  setProperty(WebLogicPropertySet.ADMIN_USER, "weblogic");
  setProperty(WebLogicPropertySet.ADMIN_PWD, "weblogic");
  setProperty(WebLogicPropertySet.SERVER, "server");
  setProperty(WebLogicPropertySet.CONFIGURATION_VERSION, "9.2.3.0");
  setProperty(WebLogicPropertySet.DOMAIN_VERSION, "9.2.3.0");
  setProperty(ServletPropertySet.PORT, "7001");
  setProperty(GeneralPropertySet.HOSTNAME, "localhost");
  namespaces = new HashMap<String, String>();
  namespaces.put("weblogic", "http://www.bea.com/ns/weblogic/920/domain");
  namespaces.put("jdbc", "http://www.bea.com/ns/weblogic/90");
  xmlTool = new XmlUtils();
  xmlTool.setNamespaces(namespaces);
  xmlTool.setFileHandler(getFileHandler());
}

代码示例来源:origin: codehaus-cargo/cargo

/**
   * Test simple element parse.
   * @throws Exception If anything does wrong.
   */
  public void testSelectElementMatchingXPath() throws Exception
  {
    Map<String, String> namespace = new HashMap<String, String>();
    namespace.put("animal", "urn:animal");
    util.setNamespaces(namespace);

    String string = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
        + "<base-element>"
        + "<element>dog</element>"
        + "<element xmlns=\"urn:animal\">cat</element>"
        + "</base-element>";
    Element element = util.parseIntoElement(string);
    Element animalElement = util.selectElementMatchingXPath("//base-element/animal:element",
        element);

    assertEquals("element", animalElement.getNodeName());
    assertEquals("cat", animalElement.getTextContent());
  }
}

代码示例来源:origin: stackoverflow.com

XmlUtils xmlUtils = new XmlUtils();
  Document diffAsDom = xmlUtils.diffToDoc(doc, 
             doc1, new Options());

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

xmlTool.selectElementsMatchingXPath("weblogic:app-deployment", domain);
for (Element appDeployment : appDeployments)
  xmlTool.selectElementMatchingXPath("weblogic:configuration-version", domain);
Node before = null;
NodeList children = domain.getChildNodes();

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-util

/**
 * {@inheritDoc}
 */
@Override
public void insertElementUnderXPath(Element elementToInsert, String xpath)
{
  Element parent = xmlUtil.selectElementMatchingXPath(xpath, document.getDocumentElement());
  Node clone = parent.getOwnerDocument().importNode(elementToInsert, true);
  parent.appendChild(clone);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-api-util

/**
 * {@inheritDoc}
 */
@Override
public void setNamespaces(Map<String, String> namespaces)
{
  xmlUtil.setNamespaces(namespaces);
}

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

/**
 * this will select the node(s) that match the below deployment.
 * 
 * @param deployable what to search for
 * @param domain root element to search in
 * @return list of child elements that match the deployment
 */
protected List<Element> selectAppDeployments(Deployable deployable, Element domain)
{
  String xpath =
    "//weblogic:app-deployment[weblogic:name/text()='"
      + createIdForDeployable(deployable) + "']";
  Element toSearch = domain;
  return xmlTool.selectElementsMatchingXPath(xpath, toSearch);
}

代码示例来源:origin: codehaus-cargo/cargo

/**
 * Test simple element parse.
 * @throws Exception If anything does wrong.
 */
public void testParsableElement() throws Exception
{
  String string = "<element>dog</element>";
  Element element = util.parseIntoElement(string);
  assertEquals("element", element.getNodeName());
  assertEquals("dog", element.getTextContent());
}

代码示例来源:origin: codehaus-cargo/cargo

throws CargoException
XmlUtils domUtils = new XmlUtils(this);
Document doc = domUtils.loadXmlFromFile(file);
domUtils.saveXml(doc, file);

代码示例来源:origin: codehaus-cargo/cargo

/**
 * {@inheritDoc} deploys files by adding their configuration to the config.xml file of the
 * WebLogic server.
 */
@Override
public void deploy(Deployable deployable)
{
  XmlUtils xmlUtil = new XmlUtils(getFileHandler());
  Document configXml =
    xmlUtil.loadXmlFromFile(getFileHandler().append(getDomainHome(), "config.xml"));
  Element domain = xmlUtil.selectElementMatchingXPath("//Domain",
    configXml.getDocumentElement());
  if (deployable.getType() == DeployableType.WAR)
  {
    addWarToDomain((WAR) deployable, domain);
  }
  else if (deployable.getType() == DeployableType.EAR)
  {
    addEarToDomain((EAR) deployable, domain);
  }
  else
  {
    throw new ContainerException("Not supported");
  }
  this.writeConfigXml(configXml);
}

代码示例来源:origin: codehaus-cargo/cargo

/**
 * {@inheritDoc} undeploys files by removing their configuration to the config.xml file of the
 * WebLogic server.
 */
@Override
public void undeploy(Deployable deployable)
{
  XmlUtils xmlUtil = new XmlUtils(getFileHandler());
  Document configXml =
    xmlUtil.loadXmlFromFile(getFileHandler().append(getDomainHome(), "config.xml"));
  List<Element> results = xmlUtil.selectElementsMatchingXPath("//Application[@Path='"
    + getFileHandler().getParent(getAbsolutePath(deployable)) + "']",
      configXml.getDocumentElement());
  for (Element element : results)
  {
    configXml.removeChild(element);
  }
  this.writeConfigXml(configXml);
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com