Package nu.xom

Examples of nu.xom.Element.addNamespaceDeclaration()


  public static Element getFixtureElement() {
    try {
      DDMSVersion version = DDMSVersion.getCurrentVersion();
      Element element = Util.buildDDMSElement(ApplicationSoftware.getName(version), TEST_VALUE);
      element.addNamespaceDeclaration(PropertyReader.getPrefix("ddms"), version.getNamespace());
      element.addNamespaceDeclaration(PropertyReader.getPrefix("ism"), version.getIsmNamespace());
      SecurityAttributesTest.getFixture().addTo(element);
      return (element);
    }
    catch (InvalidDDMSException e) {
      fail("Could not create fixture: " + e.getMessage());
View Full Code Here


   * Returns a fixture object for testing.
   */
  public static Element getFixtureElement() {
    DDMSVersion version = DDMSVersion.getCurrentVersion();
    Element element = Util.buildDDMSElement(RecordKeeper.getName(version), null);
    element.addNamespaceDeclaration(PropertyReader.getPrefix("ddms"), version.getNamespace());
    Element idElement = Util.buildDDMSElement("recordKeeperID", TEST_ID);
    element.appendChild(idElement);
    element.appendChild(OrganizationTest.getFixture().getXOMElementCopy());
    return (element);
  }
View Full Code Here

   */
  public static Element getFixtureElement(boolean useOrg) {
    try {
      DDMSVersion version = DDMSVersion.getCurrentVersion();
      Element element = Util.buildDDMSElement(Addressee.getName(version), null);
      element.addNamespaceDeclaration(PropertyReader.getPrefix("ddms"), version.getNamespace());
      element.appendChild(useOrg ? OrganizationTest.getFixture().getXOMElementCopy()
        : PersonTest.getFixture().getXOMElementCopy());
      SecurityAttributesTest.getFixture().addTo(element);
      return (element);
    }
View Full Code Here

            if (uri.equals(XMLNS_NAMESPACE)) {
                if (name.equals("xmlns")) continue;
                String prefix = name.substring(name.indexOf(':') + 1);
                String currentURI = result.getNamespaceURI(prefix);
                if (!value.equals(currentURI)) {
                    result.addNamespaceDeclaration(prefix, value);
                }
            }
            else {
                Nodes nodes = factory.makeAttribute(name, uri, value, Attribute.Type.UNDECLARED);
                for (int j = 0; j < nodes.size(); j++) {
View Full Code Here

        xomDocument.insertChild(type, 0);
        xomDocument.insertChild(new ProcessingInstruction(
         "xml-stylesheet", "href=\"file.css\" type=\"text/css\""), 1);
        xomDocument.insertChild(new Comment(" test "), 2);
        xomDocument.appendChild(new Comment("epilog"));
        root.addNamespaceDeclaration("xlink",
          "http://www.w3.org/TR/1999/xlink");
        root.appendChild("Hello dear\r\n");
        Element em = new Element("em");
        root.appendChild(em);
        em.addAttribute(new Attribute("id", "p1"));
View Full Code Here

          "http://www.w3.org/TR/1999/xlink");
        root.appendChild("Hello dear\r\n");
        Element em = new Element("em");
        root.appendChild(em);
        em.addAttribute(new Attribute("id", "p1"));
        em.addNamespaceDeclaration("none", "http://www.example.com");
        em.appendChild("very important");
        Element span = new Element("span");
        root.appendChild(span);
        span.addAttribute(new Attribute("xlink:type",
          "http://www.w3.org/TR/1999/xlink", "simple"));
View Full Code Here

       

    public void testExclusiveDoesntRenderUnusedPrefix() throws IOException {
  
      Element pdu = new Element("n0:tuck", "http://a.example");
      pdu.addNamespaceDeclaration("pre", "http://www.example.org/");
      String expected = "<n0:tuck xmlns:n0=\"http://a.example\"></n0:tuck>";
      Canonicalizer canonicalizer = new Canonicalizer(out,
        Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION_WITH_COMMENTS);
     
View Full Code Here

    public void testPredicateWithNamespaceAxis() {
       
        Element parent = new Element("Test");
        Element child = new Element("child", "http://www.example.com");
        Element grandchild = new Element("child", "http://www.example.com");
        grandchild.addNamespaceDeclaration("pre", "http://www.w3.org/");
        parent.appendChild(child);
        child.appendChild(grandchild);
       
        // Every node has at least a mapping for xml prefix.
        Nodes result = parent.query("self::*[count(namespace::*)=0]");
 
View Full Code Here

    public void testPredicateWithNamespaceAxis2() {
       
        Element parent = new Element("Test");
        Element child = new Element("child", "http://www.example.com");
        Element grandchild = new Element("child", "http://www.example.com");
        grandchild.addNamespaceDeclaration("pre", "http://www.w3.org/");
        parent.appendChild(child);
        child.appendChild(grandchild);
       
        // Every node has at least a mapping for xml prefix.
        Nodes result = parent.query("*[count(namespace::*)=0]");
 
View Full Code Here

        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        Element test = new Element("test");
        test.addNamespaceDeclaration("pre", "http://www.example.org");
        XPathContext context = XPathContext.makeNamespaceContext(test);
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));  
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.