Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlCursor$TokenType


   * </pre>
   */
  private void appendChartElement(CTGraphicalObjectData data, String id) {
    String r_namespaceUri = STRelationshipId.type.getName().getNamespaceURI();
    String c_namespaceUri = XSSFDrawing.NAMESPACE_C;
    XmlCursor cursor = data.newCursor();
    cursor.toNextToken();
    cursor.beginElement(new QName(c_namespaceUri, "chart", "c"));
    cursor.insertAttributeWithValue(new QName(r_namespaceUri, "id", "r"), id);
    cursor.dispose();
    data.setUri(c_namespaceUri);
  }
View Full Code Here


      assertEquals(3, doc.getPosOfParagraph(p));

     CTP ctp = p.getCTP();
     XWPFParagraph newP = doc.getParagraph(ctp);
     assertSame(p, newP);
     XmlCursor cursor = doc.getDocument().getBody().getPArray(0).newCursor();
     XWPFParagraph cP = doc.insertNewParagraph(cursor);
     assertSame(cP, doc.getParagraphs().get(0));
     assertEquals(5, doc.getParagraphs().size());
  }
View Full Code Here

        runs = new ArrayList<XWPFRun>();

       // Get all our child nodes in order, and process them
       //  into XWPFRuns where we can
       XmlCursor c = paragraph.newCursor();
       c.selectPath("child::*");
       while (c.toNextSelection()) {
          XmlObject o = c.getObject();
          if(o instanceof CTR) {
             runs.add(new XWPFRun((CTR)o, this));
          }
          if(o instanceof CTHyperlink) {
             CTHyperlink link = (CTHyperlink)o;
             for(CTR r : link.getRList()) {
                runs.add(new XWPFHyperlinkRun(link, r, this));
             }
          }
          if(o instanceof CTSdtRun) {
             CTSdtContentRun run = ((CTSdtRun)o).getSdtContent();
             for(CTR r : run.getRList()) {
                runs.add(new XWPFRun(r, this));
             }
          }
          if(o instanceof CTRunTrackChange) {
             for(CTR r : ((CTRunTrackChange)o).getRList()) {
                runs.add(new XWPFRun(r, this));
             }
          }
          if(o instanceof CTSimpleField) {
             for(CTR r : ((CTSimpleField)o).getRList()) {
                runs.add(new XWPFRun(r, this));
             }
          }
       }

       c.dispose();
      
       // Look for bits associated with the runs
       for(XWPFRun run : runs) {
          CTR r = run.getCTR();
         
          // Check for bits that only apply when
          //  attached to a core document
          // TODO Make this nicer by tracking the XWPFFootnotes directly
          if(document != null) {
             c = r.newCursor();
             c.selectPath("child::*");
             while (c.toNextSelection()) {
                XmlObject o = c.getObject();
                if(o instanceof CTFtnEdnRef) {
                   CTFtnEdnRef ftn = (CTFtnEdnRef)o;
                   footnoteText.append("[").append(ftn.getId()).append(": ");
                   XWPFFootnote footnote =
                      ftn.getDomNode().getLocalName().equals("footnoteReference") ?
                            document.getFootnoteByID(ftn.getId().intValue()) :
                            document.getEndnoteByID(ftn.getId().intValue());
  
                   boolean first = true;
                   for (XWPFParagraph p : footnote.getParagraphs()) {
                      if (!first) {
                         footnoteText.append("\n");
                         first = false;
                      }
                      footnoteText.append(p.getText());
                   }
  
                   footnoteText.append("]");
                }
             }
             c.dispose();
          }
      }
    }
View Full Code Here

      int beginRunPos = 0, candCharPos = 0;
      boolean newList = false;
      for (int runPos=startRun; runPos<paragraph.getRList().size(); runPos++) {
        int beginTextPos = 0,beginCharPos = 0, textPos = 0,  charPos = 0
        CTR ctRun = paragraph.getRArray(runPos);
        XmlCursor c = ctRun.newCursor();
        c.selectPath("./*");
        while(c.toNextSelection()){
          XmlObject o = c.getObject();
          if(o instanceof CTText){
            if(textPos>=startText){
              String candidate = ((CTText)o).getStringValue();
              if(runPos==startRun)
                charPos= startChar;
              else
                charPos = 0
              for(; charPos<candidate.length(); charPos++){
                if((candidate.charAt(charPos)==searched.charAt(0))&&(candCharPos==0)){
                  beginTextPos = textPos;
                  beginCharPos = charPos;
                  beginRunPos = runPos;
                  newList = true;
                }
                if(candidate.charAt(charPos)==searched.charAt(candCharPos)){
                  if(candCharPos+1<searched.length())
                    candCharPos++;
                  else if(newList){
                    TextSegement segement = new TextSegement();
                    segement.setBeginRun(beginRunPos);
                    segement.setBeginText(beginTextPos);
                    segement.setBeginChar(beginCharPos);
                    segement.setEndRun(runPos);
                    segement.setEndText(textPos);
                    segement.setEndChar(charPos);
                    return segement;
                  }
                }
                else
                  candCharPos=0;
              }
            }
            textPos++;
          }
          else if(o instanceof CTProofErr){
            c.removeXml();
          }
          else if(o instanceof CTRPr);
            //do nothing
          else
            candCharPos=0;
        }

            c.dispose();
      }
      return null;
    }
View Full Code Here

        XmlOptions xmlOptions = XmlBeansUtil.createXmlOptions(errors);
        SchemaDocument parsed = SchemaDocument.Factory.parse(element, xmlOptions);
        if (errors.size() != 0) {
            throw new XmlException(errors.toArray().toString());
        }
        XmlCursor cursor = parsed.newCursor();
        try {
            cursor.toFirstContentToken();
            for (Iterator namespaces = namespaceMap.entrySet().iterator(); namespaces.hasNext();) {
                Map.Entry entry = (Map.Entry) namespaces.next();
                cursor.insertNamespace((String) entry.getKey(), (String) entry.getValue());
            }
        } finally {
            cursor.dispose();
        }
        return parsed;
    }
View Full Code Here

            TService service = services[i];
            TPort[] ports = service.getPortArray();
            for (int j = 0; j < ports.length; j++) {
                TPort port = ports[j];
                if (port.getName().trim().equals(portComponentName)) {
                    XmlCursor portCursor = port.newCursor();
                    try {
                        if (portCursor.toChild(ADDRESS_QNAME)) {
                            if (servletLocation == null) {
                                String original = portCursor.getAttributeText(LOCATION_QNAME);
                                URI originalURI = new URI(original);
                                servletLocation = originalURI.getPath();
                            }
                            portCursor.setAttributeText(LOCATION_QNAME, WebServiceContainer.LOCATION_REPLACEMENT_TOKEN + servletLocation);
                            return servletLocation;
                        }
                    } catch (URISyntaxException e) {
                        throw new DeploymentException("Could not construct URI for ejb location in wsdl", e);
                    } finally {
                        portCursor.dispose();
                    }
                }
            }
        }
        throw new DeploymentException("No port found with name " + portComponentName + " expected at " + servletLocation);
View Full Code Here

        this.namespace = namespace;
        this.element = element;
    }

    public XmlObject convertToSpecificPlan(XmlObject plan) throws DeploymentException {
        XmlCursor rawCursor = plan.newCursor();
        try {
            if (SchemaConversionUtils.findNestedElement(rawCursor, "web-app")) {
                XmlCursor temp = rawCursor.newCursor();
                String namespace = temp.getName().getNamespaceURI();
                temp.dispose();
                if(!namespace.equals(GENERIC_NAMESPACE) && !namespace.equals(this.namespace) && !namespace.equals(OLD_GENERIC_NAMESPACE)) {
                    throw new DeploymentException("Cannot handle web plan with namespace "+namespace+" -- expecting "+GENERIC_NAMESPACE+" or "+this.namespace);
                }

                XmlObject webPlan = rawCursor.getObject().copy();

                XmlCursor cursor = webPlan.newCursor();
                XmlCursor end = cursor.newCursor();
                try {
                    cursor.push();
                    if (cursor.toChild(GENERIC_CONFIG_QNAME) || cursor.toChild(OLD_GENERIC_CONFIG_QNAME)) {
                        XmlCursor source = cursor.newCursor();
                        cursor.push();
                        cursor.toEndToken();
                        cursor.toNextToken();
                        try {
                            if (source.toChild(configNamespace, element)) {
                                source.copyXmlContents(cursor);
                            }

                        } finally {
                            source.dispose();
                        }
                        cursor.pop();
                        cursor.removeXml();
                    }
                    cursor.pop();
                    cursor.push();
                    while (cursor.hasNextToken()) {
                        if (cursor.isStart()) {
                            if (!SchemaConversionUtils.convertSingleElementToGeronimoSubSchemas(cursor, end)
                            && !this.namespace.equals(cursor.getName().getNamespaceURI())) {
                                cursor.setName(new QName(this.namespace, cursor.getName().getLocalPart()));
                            }
                        }
                        cursor.toNextToken();
                    }
                    //move security elements after refs

                    cursor.pop();
                    cursor.push();
                    if (cursor.toChild(this.namespace, "security-realm-name")) {
                        XmlCursor other = cursor.newCursor();
                        try {
                            other.toParent();
                            if (other.toChild(SYSTEM_NAMESPACE, "gbean")) {
                                other.toPrevToken();
                            } else {
                                other.toEndToken();
                                other.toPrevToken();
                            }
                            cursor.moveXml(other);
                            cursor.pop();
                            cursor.push();
                            if (cursor.toChild(SECURITY_QNAME)) {
                                cursor.moveXml(other);
                            }
                        } finally {
                            other.dispose();
                        }
                    }
                    cursor.pop();
                    return webPlan;
                } finally {
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

    static ConnectorDocument convertToConnectorSchema(XmlObject xmlObject) throws XmlException {
        if (ConnectorDocument.type.equals(xmlObject.schemaType())) {
            XmlBeansUtil.validateDD(xmlObject);
            return (ConnectorDocument) xmlObject;
        }
        XmlCursor cursor = xmlObject.newCursor();
        XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
        String publicId = xmlDocumentProperties.getDoctypePublicId();
        try {
            if ("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN".equals(publicId)) {
                XmlCursor moveable = xmlObject.newCursor();
                try {
                    String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
                    String version = "1.5";
                    SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version);
                    cursor.toStartDoc();
                    cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "connector");
                    cursor.toFirstChild();
                    SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.J2EE_NAMESPACE, cursor, moveable);
                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "spec-version");
                    cursor.removeXml();
                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "version");
                    cursor.setName(RESOURCE_ADAPTER_VERSION);
                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "resourceadapter");
                    moveable.toCursor(cursor);
                    cursor.toFirstChild();
                    cursor.beginElement("outbound-resourceadapter", SchemaConversionUtils.J2EE_NAMESPACE);
                    cursor.beginElement("connection-definition", SchemaConversionUtils.J2EE_NAMESPACE);
                    moveable.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "managedconnectionfactory-class");
                    moveable.push();
                    //from moveable to cursor
                    moveable.moveXml(cursor);
                    while (moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "config-property")) {
                        moveable.moveXml(cursor);
                    }
                    moveable.pop();
                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connectionfactory-interface");
                    moveable.moveXml(cursor);
                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connectionfactory-impl-class");
                    moveable.moveXml(cursor);
                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connection-interface");
                    moveable.moveXml(cursor);
                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "connection-impl-class");
                    moveable.moveXml(cursor);
                    //get out of connection-definition element
                    cursor.toNextToken();
                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "transaction-support");
                    moveable.moveXml(cursor);
                    while (moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "authentication-mechanism")) {
                        moveable.moveXml(cursor);
                    }
                    moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "reauthentication-support");
                    moveable.moveXml(cursor);
                } finally {
                    moveable.dispose();
                }

            }
        } finally {
            cursor.dispose();
View Full Code Here

    private static final QName CREDENTIAL_INTERFACE_QNAME = new QName(ConnectorModuleBuilder.GERCONNECTOR_NAMESPACE, "credential-interface");


    static void rectifyPlan(GerConnectorType gerConnector) {
        boolean updated = false;
        XmlCursor cursor = gerConnector.newCursor();
        try {
            updated = cursor.removeAttribute(VERSION_QNAME);
        } finally {
            cursor.dispose();
        }
        GerResourceadapterType[] resourceAdapters = gerConnector.getResourceadapterArray();
        for (int i = 0; i < resourceAdapters.length; i++) {
            GerResourceadapterType resourceAdapter = resourceAdapters[i];
            if (resourceAdapter.isSetOutboundResourceadapter()) {
            GerConnectionDefinitionType[] connectionDefinitions = resourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray();
                for (int j = 0; j < connectionDefinitions.length; j++) {
                    GerConnectionDefinitionType connectionDefinition = connectionDefinitions[j];
                    GerConnectiondefinitionInstanceType[] connectiondefinitionInstances = connectionDefinition.getConnectiondefinitionInstanceArray();
                    for (int k = 0; k < connectiondefinitionInstances.length; k++) {
                        GerConnectiondefinitionInstanceType connectiondefinitionInstance = connectiondefinitionInstances[k];
                        cursor = connectiondefinitionInstance.newCursor();
                        try {
                            if (cursor.toFirstChild()) {
                                if (cursor.toNextSibling(GLOBAL_JNDI_NAME_QNAME)) {
                                    cursor.removeXml();
                                    updated = true;
                                }
                                if (cursor.toNextSibling(CREDENTIAL_INTERFACE_QNAME)) {
                                    cursor.removeXml();
                                    updated = true;
                                }
                            }
                        } finally {
                            cursor.dispose();
                        }
                    }
                }
            }
        }
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.