Package org.docx4j.openpackaging.parts

Examples of org.docx4j.openpackaging.parts.CustomXmlDataStoragePart


        // OK, this one looks ok
        String itemId = xp.getDataBinding().getStoreItemID().toLowerCase();
        System.out.println("Attempting to use item id: " + itemId);
       
        CustomXmlDataStoragePart customXmlDataStoragePart
          = (CustomXmlDataStoragePart)wordMLPackage.getCustomXmlDataStorageParts().get(itemId);
        if (customXmlDataStoragePart==null) {
          log.warn("Couldn't find CustomXmlDataStoragePart referenced from " + XmlUtils.marshaltoString(xp));
          continue;     
        } else {
View Full Code Here


   
    // TODO: remove any images in package which are no longer used.
    // Needs to be done once after BindingHandler has been done
    // for all parts for which it is to be called (eg mdp, header parts etc).
   
    CustomXmlDataStoragePart part = customXmlDataStorageParts.get(storeItemId.toLowerCase());
    if (part==null) {
      log.error("Couldn't locate part by storeItemId " + storeItemId);
      return null;
    }
    try {
      String xpResult = part.getData().xpathGetString(xpath, prefixMappings);
      log.debug(xpath + " yielded result length" + xpResult.length());
     
      // Base64 decode it
      byte[] bytes = Base64.decodeBase64( xpResult.getBytes("UTF8") );
     
View Full Code Here

    // TODO: remove any images in package which are no longer used.
    // Needs to be done once after BindingHandler has been done
    // for all parts for which it is to be called (eg mdp, header parts etc).
   
    CustomXmlDataStoragePart part = customXmlDataStorageParts.get(storeItemId.toLowerCase());
    if (part==null) {
      log.error("Couldn't locate part by storeItemId " + storeItemId);
      return null;
    }
    try {
      String xpResult = part.getData().xpathGetString(xpath, prefixMappings);
      log.debug(xpath + " yielded result length" + xpResult.length());
     
      // Base64 decode it
      byte[] bytes = Base64.decodeBase64( xpResult.getBytes("UTF8") );
     
View Full Code Here

   *  Bind the content controls of the passed document to the xml.
   */ 
  public static void bind(WordprocessingMLPackage wmlPackage, Document xmlDocument, int flags) throws Docx4JException {
   
    OpenDoPEHandler  openDoPEHandler = null;
    CustomXmlDataStoragePart customXmlDataStoragePart = null;
    RemovalHandler removalHandler = null;
    //String xpathStorageItemId = null;
   
    AtomicInteger bookmarkId = null;

View Full Code Here

    // Get the part
    // First we need to get the part.  There are a few different ways to do this.
   
    // If we know the itemId ..
    String itemId = "{5448916C-134B-45E6-B8FE-88CC1FFC17C3}".toLowerCase();
    CustomXmlDataStoragePart customXmlDataStoragePart = (CustomXmlDataStoragePart)wordMLPackage.getCustomXmlDataStorageParts().get(itemId);
    // .. if you don't know the itemId (which you can get using ContentControlsPartsInfo),
    // you could get the part by name, by type,
    // or you could find the item Id by looking in an SDT for w:storeItemID:
    //  <w:sdt>
    //    <w:sdtPr>
    //      <w:dataBinding w:prefixMappings="" w:xpath="/myxml[1]/element1[1]"
    //          w:storeItemID="{5448916C-134B-45E6-B8FE-88CC1FFC17C3}"/>
    //    </w:sdtPr>
    //    <w:sdtContent>   
   
    // Get the contents   
    CustomXmlDataStorage customXmlDataStorage = customXmlDataStoragePart.getData();
      // In a real program what you might do is populate this with your own data.
      // You could replace the whole part (as is done in https://github.com/plutext/OpenDoPE-WAR/blob/master/webapp-simple/src/main/java/org/opendope/webapp/SubmitBoth.java ),
        // or as we show below, just set some particular value
   
       
View Full Code Here

      .addStyledParagraphOfText("Title", "Hello world");

    wordMLPackage.getMainDocumentPart().addParagraphOfText("from docx4j!");
   
           
    CustomXmlDataStoragePart customXmlDataStoragePart = injectCustomXmlDataStoragePart(
        wordMLPackage.getMainDocumentPart() );
   
    addProperties(customXmlDataStoragePart);
   
    // Now save it
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.CustomXmlDataStoragePart

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.