Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlCursor


 
  public XWPFHeader(XWPFDocument doc, CTHdrFtr hdrFtr) throws IOException {
    super(doc, hdrFtr);
    paragraphs = new ArrayList<XWPFParagraph>();
    tables = new ArrayList<XWPFTable>();
    XmlCursor cursor = headerFooter.newCursor();
    cursor.selectPath("./*");
    while (cursor.toNextSelection()) {
      XmlObject o = cursor.getObject();
      if (o instanceof CTP) {
        XWPFParagraph p = new XWPFParagraph((CTP) o, this);
        paragraphs.add(p);
      }
      if (o instanceof CTTbl) {
        XWPFTable t = new XWPFTable((CTTbl) o, this);
        tables.add(t);
      }
    }
        cursor.dispose();
    getAllPictures();
  }
View Full Code Here


     * @param xs    the string to check
     */
    protected static void preserveSpaces(STXstring xs) {
        String text = xs.getStringValue();
        if (text != null && (text.startsWith(" ") || text.endsWith(" "))) {
            XmlCursor c = xs.newCursor();
            c.toNextToken();
            c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve");
            c.dispose();
        }
    }
View Full Code Here

        is = getPackagePart().getInputStream();
        hdrDocument = HdrDocument.Factory.parse(is);
        headerFooter = hdrDocument.getHdr();
            // parse the document with cursor and add
            // the XmlObject to its lists
        XmlCursor cursor = headerFooter.newCursor();
            cursor.selectPath("./*");
            while (cursor.toNextSelection()) {
                XmlObject o = cursor.getObject();
                if (o instanceof CTP) {
                  XWPFParagraph p = new XWPFParagraph((CTP)o, this);
                  paragraphs.add(p);
                  bodyElements.add(p);
                }
                if (o instanceof CTTbl) {
                  XWPFTable t = new XWPFTable((CTTbl)o, this);
                  tables.add(t);
                  bodyElements.add(t);
                }
            }
                cursor.dispose();
            getAllPictures();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (XmlException e) {
View Full Code Here

     * @param xs    the string to check
     */
    static void preserveSpaces(XmlString xs) {
        String text = xs.getStringValue();
        if (text != null && (text.startsWith(" ") || text.endsWith(" "))) {
            XmlCursor c = xs.newCursor();
            c.toNextToken();
            c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve");
            c.dispose();
        }
    }
View Full Code Here

    public String toString() {
       StringBuffer text = new StringBuffer();
      
       // 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 CTEmpty) {
              // Some inline text elements get returned not as
              //  themselves, but as CTEmpty, owing to some odd
              //  definitions around line 5642 of the XSDs
              String tagName = o.getDomNode().getNodeName();
              if ("w:tab".equals(tagName)) {
                 text.append("\t");
              }
              if ("w:br".equals(tagName)) {
                 text.append("\n");
              }
              if ("w:cr".equals(tagName)) {
                 text.append("\n");
              }
           }
       }

       c.dispose();
      
       // Any picture text?
       if(pictureText != null && pictureText.length() > 0) {
          text.append("\n").append(pictureText);
       }
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

//        log.debug(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application_5.xsd";
            String version = "5";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = AppClientModuleBuilder.convertToApplicationClientSchema(xmlObject);
View Full Code Here

//        log.debug(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/application_5.xsd";
            String version = "5";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = AppClientModuleBuilder.convertToApplicationClientSchema(xmlObject);
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

            if (gerConnector == null) {
                throw new DeploymentException("A connector module must be deployed using a Geronimo deployment plan" +
                        " (either META-INF/geronimo-ra.xml in the RAR file or a standalone deployment plan passed to the deployer).");
            }
            ConnectorPlanRectifier.rectifyPlan(gerConnector);
            XmlCursor cursor = gerConnector.newCursor();
            try {
                SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            } finally {
                cursor.dispose();
            }

            XmlBeansUtil.validateDD(gerConnector);
        } catch (XmlException e) {
            throw new DeploymentException("Could not parse module descriptor", e);
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlCursor

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.