Examples of XmlObject


Examples of org.apache.xmlbeans.XmlObject

       // Grab the text and tabs of the text run
       // Do so in a way that preserves the ordering
       XmlCursor c = run.newCursor();
       c.selectPath("./*");
       while (c.toNextSelection()) {
           XmlObject o = c.getObject();
           if (o instanceof CTText) {
               String tagName = o.getDomNode().getNodeName();
               // Field Codes (w:instrText, defined in spec sec. 17.16.23)
               //  come up as instances of CTText, but we don't want them
               //  in the normal text output
               if (!"w:instrText".equals(tagName)) {
                  text.append(((CTText) o).getStringValue());
               }
           }
          
           if (o instanceof CTPTab) {
               text.append("\t");
           }
           if (o instanceof CTBr) {
              text.append("\n");
           }
           if (o instanceof CTEmpty) {
              // Some inline text elements get returned not as
              //  themselves, but as CTEmpty, owing to some odd
              //  definitions around line 5642 of the XSDs
              // This bit works around it, and replicates the above
              //  rules for that case
              String tagName = o.getDomNode().getNodeName();
              if ("w:tab".equals(tagName)) {
                 text.append("\t");
              }
              if ("w:br".equals(tagName)) {
                 text.append("\n");
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

    private void doTest(String text) throws XmlException, DeploymentException {
        GeronimoSecurityBuilderImpl secBuilder = new GeronimoSecurityBuilderImpl(null);
        secBuilder.doStart();
        LoginConfigBuilder builder = new LoginConfigBuilder(new Jsr77Naming(), null);
        XmlObject xmlObject = XmlBeansUtil.parse(text);
        XmlCursor cursor = xmlObject.newCursor();
        cursor.toFirstContentToken();
        xmlObject = cursor.getObject();
        DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1.0/car")), null, ConfigurationModuleType.SERVICE, new Jsr77Naming(), new MockConfigurationManager(), Collections.emptySet());
        AbstractName parentName = new AbstractName(URI.create("test/foo/1.0/car?name=parent,j2eeType=foo"));
        builder.getReferences(xmlObject, context, parentName, getClass().getClassLoader());
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

        try {
            // before saving, make sure the directory is present
            ensureMonitorDir();

            //TODO GERONIMO-3719.  Hack to use xmlbeans to write out xml instead of sun specific classes.
            XmlObject xmlObject = XmlObject.Factory.parse(document.getDocumentElement());
            xmlObject.save(new File(path));

            // formatting the doc
//            OutputFormat format = new OutputFormat(document);
//            format.setIndenting(true);
            // generate a file output
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

    }

    private WebAppType getWebApp(JarFile dummyFile) throws IOException, XmlException {
        URL specDDUrl = DeploymentUtil.createJarURL(dummyFile, "WEB-INF/web.xml");
        XmlObject parsed = XmlBeansUtil.parse(specDDUrl, getClass().getClassLoader());
        WebAppDocument webAppDoc = (WebAppDocument) parsed.changeType(WebAppDocument.type);
        return webAppDoc.getWebApp();
    }
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

    }

    public void xtestConvertToJettySchema() throws Exception {
        URL resourcePlan = classLoader.getResource("plans/plan4.xml");
        assertTrue(resourcePlan != null);
        XmlObject rawPlan = XmlBeansUtil.parse(resourcePlan, getClass().getClassLoader());
        XmlObject webPlan = new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
                JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI(), "jetty").convertToSpecificPlan(rawPlan);
        URL ConvertedPlan = classLoader.getResource("plans/plan4-converted.xml");
        assertTrue(ConvertedPlan != null);
        XmlObject converted = XmlBeansUtil.parse(ConvertedPlan, getClass().getClassLoader());
        XmlCursor c = converted.newCursor();
        SchemaConversionUtils.findNestedElement(c, JettyWebAppDocument.type.getDocumentElementName());
        c.toFirstChild();
        ArrayList problems = new ArrayList();
        compareXmlObjects(webPlan, c.getObject(), problems);
        assertEquals("problems: " + problems, 0, problems.size());
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
            // on the J2ee management object
            specDD = DeploymentUtil.readAll(specDDUrl);

            // we found web.xml, if it won't parse that's an error.
            XmlObject parsed = XmlBeansUtil.parse(specDD);
            //Dont save updated xml if it isn't javaee
            XmlCursor cursor = parsed.newCursor();
            try {
                cursor.toStartDoc();
                cursor.toFirstChild();
                isJavaee = "http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI());
            } finally {
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

        return contextRoot;
    }


    TomcatWebAppType getTomcatWebApp(Object plan, JarFile moduleFile, boolean standAlone, String targetPath, WebAppType webApp) throws DeploymentException {
        XmlObject rawPlan = null;
        try {
            // load the geronimo-web.xml from either the supplied plan or from the earFile
            try {
                if (plan instanceof XmlObject) {
                    rawPlan = (XmlObject) plan;
                } else {
                    if (plan != null) {
                        rawPlan = XmlBeansUtil.parse(((File) plan).toURL(), getClass().getClassLoader());
                    } else {
                        URL path = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/geronimo-web.xml");
                        try {
                            rawPlan = XmlBeansUtil.parse(path, getClass().getClassLoader());
                        } catch (FileNotFoundException e) {
                            path = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/geronimo-tomcat.xml");
                            try {
                                rawPlan = XmlBeansUtil.parse(path, getClass().getClassLoader());
                            } catch (FileNotFoundException e1) {
                                log.warn("Web application " + targetPath + " does not contain a WEB-INF/geronimo-web.xml deployment plan.  This may or may not be a problem, depending on whether you have things like resource references that need to be resolved.  You can also give the deployer a separate deployment plan file on the command line.");
                            }
                        }
                    }
                }
            } catch (IOException e) {
                log.warn(e);
            }

            TomcatWebAppType tomcatWebApp;
            if (rawPlan != null) {
                XmlObject webPlan = new GenericToSpecificPlanConverter(GerTomcatDocument.type.getDocumentElementName().getNamespaceURI(),
                        TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI(), "tomcat").convertToSpecificPlan(rawPlan);
                tomcatWebApp = (TomcatWebAppType) webPlan.changeType(TomcatWebAppType.type);
                XmlBeansUtil.validateDD(tomcatWebApp);
            } else {
                tomcatWebApp = createDefaultPlan();
            }
            return tomcatWebApp;
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

            GerConnectorDocument doc = GerConnectorDocument.Factory.newInstance();
            doc.addNewConnector().addNewResourceadapter();
            return doc;
        } else {
            try {
                XmlObject result =  GerConnectorDocument.Factory.parse(in);
                in.close();
                return result;
            } catch (XmlException e) {
                throw new RuntimeException("Unable to load default Geronimo RA data", e);
            } catch (IOException e) {
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

    //The schemas have been fixed by sun, we can use the official schemas.

    public void testOrderDescriptionGroup() throws Exception {
        URL srcXml = classLoader.getResource("j2ee_1_3dtd/DescriptionGroupTestSource.xml");
        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/DescriptionGroupTestExpected.xml");
        XmlObject srcObject = XmlObject.Factory.parse(srcXml);
        XmlCursor srcCursor = srcObject.newCursor();
        XmlCursor moveable = srcObject.newCursor();
        try {
            srcCursor.toFirstChild();
            srcCursor.toFirstChild();
            assertTrue(srcCursor.getName().toString(), "filter".equals(srcCursor.getName().getLocalPart()));
            do {
                srcCursor.push();
                srcCursor.toFirstChild();
                SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE, srcCursor, moveable);
                srcCursor.pop();
            } while (srcCursor.toNextSibling());
        } finally {
            srcCursor.dispose();
        }
//        log.debug(srcObject.toString());
        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(srcObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.xmlbeans.XmlObject

    }

    public void testOrderJNDIEnvironmentRefsGroup() throws Exception {
        URL srcXml = classLoader.getResource("j2ee_1_3dtd/JNDIEnvironmentRefsGroupTestSource.xml");
        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/JNDIEnvironmentRefsGroupTestExpected.xml");
        XmlObject srcObject = XmlObject.Factory.parse(srcXml);
        XmlCursor srcCursor = srcObject.newCursor();
        XmlCursor moveable = srcObject.newCursor();
        try {
            srcCursor.toFirstChild();
            srcCursor.toFirstChild();
            assertTrue(srcCursor.getName().toString(), "web-app".equals(srcCursor.getName().getLocalPart()));
            do {
                srcCursor.push();
                srcCursor.toFirstChild();
                srcCursor.toNextSibling();
                srcCursor.toNextSibling();
                moveable.toCursor(srcCursor);
                SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.J2EE_NAMESPACE, srcCursor, moveable);
                srcCursor.pop();
            } while (srcCursor.toNextSibling());
        } finally {
            srcCursor.dispose();
        }
//        log.debug(srcObject.toString());
        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(srcObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
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.