Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlCursor$TokenType


    public void testGBeanElementConverter() throws Exception {
        URL srcXml = classLoader.getResource("geronimo/gbean-pre.xml");
        URL expectedOutputXml = classLoader.getResource("geronimo/gbean-post.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        ElementConverter elementConverter = new GBeanElementConverter();
        XmlCursor cursor = xmlObject.newCursor();
        XmlCursor end = cursor.newCursor();
        try {
            elementConverter.convertElement(cursor, end);
            //        log.debug(xmlObject.toString());
            XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
            List problems = new ArrayList();
            boolean ok = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok);
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok2);
        } finally {
            cursor.dispose();
            end.dispose();
        }

    }
View Full Code Here


    public void testQNameConverter1() throws Exception {
        URL srcXml = classLoader.getResource("geronimo/qname1-pre.xml");
        URL expectedOutputXml = classLoader.getResource("geronimo/qname1-post.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        ElementConverter elementConverter = new QNameConverter("import", "http://geronimo.apache.org/xml/ns/deployment-1.0", "parent");
        XmlCursor cursor = xmlObject.newCursor();
        XmlCursor end = cursor.newCursor();
        try {
            elementConverter.convertElement(cursor, end);
            //        log.debug(xmlObject.toString());
            XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
            List problems = new ArrayList();
            boolean ok = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok);
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok2);
        } finally {
            cursor.dispose();
            end.dispose();
        }

    }
View Full Code Here

    public void testQNameConverter2() throws Exception {
        URL srcXml = classLoader.getResource("geronimo/qname2-pre.xml");
        URL expectedOutputXml = classLoader.getResource("geronimo/qname2-post.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        ElementConverter elementConverter = new QNameConverter("import", "http://geronimo.apache.org/xml/ns/deployment-1.0", "parent");
        XmlCursor cursor = xmlObject.newCursor();
        XmlCursor end = cursor.newCursor();
        try {
            elementConverter.convertElement(cursor, end);
            //        log.debug(xmlObject.toString());
            XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
            List problems = new ArrayList();
            boolean ok = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok);
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok2);
        } finally {
            cursor.dispose();
            end.dispose();
        }

    }
View Full Code Here

    }
    public void testWebMessageDestination1() throws Exception {
        URL srcXml = classLoader.getResource("geronimo/web-md-pre.xml");
        URL expectedOutputXml = classLoader.getResource("geronimo/web-md-post.xml");
        XmlObject xmlObject = XmlBeansUtil.parse(srcXml, this.getClass().getClassLoader());
        XmlCursor cursor = xmlObject.newCursor();
        try {
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            log.debug(xmlObject.toString());
           
            XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
            log.debug(expected.toString());
           
            List problems = new ArrayList();
            boolean ok = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok);
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok2);
        } finally {
            cursor.dispose();
        }

    }
View Full Code Here

        Float floatVal = new Float(123.456);
        Double doubleVal = new Double(12345.6789);
        Boolean booleanVal = Boolean.TRUE;

        XmlObject doc = XmlObject.Factory.parse(TEST);
        XmlCursor cursor = doc.newCursor();
        try {
            cursor.toFirstChild();
            doc = cursor.getObject();
        } finally {
            cursor.dispose();
        }
        environmentEntryBuilder.buildNaming(doc, null, null, componentContext);
        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(NamingBuilder.JNDI_KEY.get(componentContext));
        Set actual = new HashSet();
        for (NamingEnumeration e = context.listBindings("env"); e.hasMore();) {
View Full Code Here

                throw new DeploymentException(e);
            }
        }

        if (unknownXmlObject != null) {
            XmlCursor xmlCursor = unknownXmlObject.newCursor();
            //
            QName qname = xmlCursor.getName();
            if (qname == null) {
                xmlCursor.toFirstChild();
                qname = xmlCursor.getName();
            }
            if (qname.getLocalPart().equals("openejb-jar")) {
                ejbModule.getAltDDs().put("openejb-jar.xml", xmlCursor.xmlText());
            } else if (qname.getLocalPart().equals("ejb-jar") && qname.getNamespaceURI().equals("http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0")) {
                ejbModule.getAltDDs().put("geronimo-openejb.xml", xmlCursor.xmlText());
            }
        }

        // Read in the deploument desiptor files
        ReadDescriptors readDescriptors = new ReadDescriptors();
View Full Code Here

                    }
                }
            }
        }
        // Copy the content into the XmlAttributeType
        XmlCursor loginCursor = lcDoc.newCursor();
        loginCursor.toFirstContentToken();
        XmlCursor destination = config.newCursor();
        destination.toNextToken();
        loginCursor.moveXml(destination);
        loginCursor.dispose();
        destination.dispose();
        config.setName("LoginModuleConfiguration");
        root.setServiceArray(new AbstractServiceType[]{realm});


        //Above code inserts gbean using xsi:type=dep:GBeanType.  We also need to account for the substitution group
        //by changing the qname:
        XmlCursor gbeanCursor = root.newCursor();
        try {
            if (!gbeanCursor.toChild(ServiceDocument.type.getDocumentElementName())) {
                throw new RuntimeException("Could not find service element");
            }
            gbeanCursor.setName(GBEAN_QNAME);
        } finally {
            gbeanCursor.dispose();
        }

        return doc;
    }
View Full Code Here

        return result;
    }

    protected static XmlObject convert(XmlObject xmlObject, NamespaceElementConverter converter, SchemaType type) throws DeploymentException {
        Map ns = new HashMap();
        XmlCursor cursor = xmlObject.newCursor();
        try {
            cursor.getAllNamespaces(ns);
        } finally {
            cursor.dispose();
        }
        xmlObject = xmlObject.copy();
        cursor = xmlObject.newCursor();
        cursor.toNextToken();
        try {
            for (Object o : ns.entrySet()) {
                Map.Entry entry = (Map.Entry) o;
                cursor.insertNamespace((String) entry.getKey(), (String) entry.getValue());
            }
        } finally {
            cursor.dispose();
        }

        if (xmlObject.schemaType() != type) {
            converter.convertElement(xmlObject);
            xmlObject = xmlObject.changeType(type);
View Full Code Here

        }
    }

    private XmlObject parse(String xmlString) throws XmlException {
        XmlObject xmlObject = XmlObject.Factory.parse(xmlString);
        XmlCursor xmlCursor = xmlObject.newCursor();
        try {
            xmlCursor.toFirstChild();
            return xmlCursor.getObject();
        } finally {
            xmlCursor.dispose();
        }
    }
View Full Code Here

  /**
   * verifies that cursor is on the right position
   * @param cursor
   */
  private boolean isCursorInBody(XmlCursor cursor) {
    XmlCursor verify = cursor.newCursor();
    verify.toParent();
    if(verify.getObject() == this.ctDocument.getBody()){
      return true;
    }
    XmlObject o = verify.getObject();
    return false;
   
  }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlCursor$TokenType

Copyright © 2018 www.massapicom. 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.