congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
JaxbXmlPart
Code IndexAdd Tabnine to your IDE (free)

How to use
JaxbXmlPart
in
org.docx4j.openpackaging.parts

Best Java code snippets using org.docx4j.openpackaging.parts.JaxbXmlPart (Showing top 20 results out of 315)

origin: plutext/docx4j

  protected static void shallowCopyContent(Part source, Part destination) throws Docx4JException {
    if (source instanceof BinaryPart) {
      ((BinaryPart)destination).setBinaryData(((BinaryPart)source).getBuffer());
    }
    else if (source instanceof JaxbXmlPart) {
      ((JaxbXmlPart)destination).setJaxbElement(((JaxbXmlPart)source).getJaxbElement());
      ((JaxbXmlPart)destination).setJAXBContext(((JaxbXmlPart)source).getJAXBContext());
    }
    else if (source instanceof CustomXmlDataStoragePart) {
      ((CustomXmlDataStoragePart)destination).setData(((CustomXmlDataStoragePart)source).getData());
    }
    else if (source instanceof XmlPart) {
      ((XmlPart)destination).setDocument(((XmlPart)source).getDocument());
    }
    else {
      throw new IllegalArgumentException("Dont know how to handle a part of type " + source.getClass().getName());
    }
  }
}
origin: plutext/docx4j

getContents();
setMceIgnorable( (McIgnorableNamespaceDeclarator) namespacePrefixMapper);
if (this.getMceIgnorable()!=null) {
  mceIgnorable = this.getMceIgnorable();
  NamespacePrefixMapperUtils.declareNamespaces(mceIgnorable + getMcChoiceNamespaces(), doc);
  log.debug( "canonicalizeSubtree with inclusiveNamespaces {}, {}", this.getMceIgnorable(), getMcChoiceNamespaces() );
  byte[] bytes = c.canonicalizeSubtree(doc, this.getMceIgnorable()  + getMcChoiceNamespaces());
      mceIgnorable + getMcChoiceNamespaces());  
      boolean isNew = (this.getPackage()==null) ? true : this.getPackage().isNew(); // handle edge cases eg unit test where there is no package 
  marshaller.setListener(new Docx4jMarshallerListener(xsww, this.getPackage().isNew()));
  ((McIgnorableNamespaceDeclarator) namespacePrefixMapper).setMcIgnorable(mceIgnorable + getMcChoiceNamespaces());
origin: plutext/docx4j

@Override
public void afterUnmarshal(Object target, Object parent) {
  
   if (target instanceof AlternateContent.Choice) {
     
     AlternateContent.Choice choice = (AlternateContent.Choice)target;
     //System.out.print("after, Need to declare " + choice.getRequires() );
     
     if (choice.getRequires()!=null) {
       part.addMcChoiceNamespace(choice.getRequires());
     }
     if (choice.getIgnorable()!=null) {
       part.addMcChoiceNamespace(choice.getIgnorable());
     }
     if (choice.getMustUnderstand()!=null) {
       part.addMcChoiceNamespace(choice.getMustUnderstand());
     }
   }
 }
origin: plutext/docx4j

public void scramble(JaxbXmlPart p) {
  
  log.info("\n\n Scrambling " + p.getPartName().getName());
  
  new TraversalUtil(p.getJaxbElement(), latinizer);
  
  
}
 
origin: plutext/docx4j

if (this.getPackage()==null) {
  log.warn("This part not added to a package, so its contents can't be retrieved. " );
  return null;
PartStore partStore = this.getPackage().getSourcePartStore();
if (partStore==null) {
  log.info("No PartStore defined for this package (it was probably created, not loaded). " );
  log.info(this.getPartName().getName() + ": did you initialise its contents to something?");
  return null;
  String name = this.getPartName().getName();
      this.setContentLengthAsLoaded(
          partStore.getPartSize( name.substring(1)));
      && this.getContentLengthAsLoaded()>MAX_BYTES_Unmarshal_Error) {
    throw new PartTooLargeException(this.getPartName() + ", length " + this.getContentLengthAsLoaded() + " exceeds your configured maximum allowed size for unmarshal.");
  } else {
    log.debug("Lazily unmarshalling " + name);
    unmarshal( is );
  throw new Docx4JException("Problem with part " + this.getPartName(), e);
origin: plutext/docx4j

private void process(JaxbXmlPart part) throws Docx4JException {
  log.info("/n Processing " + part.getPartName().getName() );
    = part.getPackage();		
      part.getJaxbElement() ); 	
      part.setJaxbElement(result);
        part.setJaxbElement(o);
      } else 
        part.setJaxbElement(o);
origin: plutext/docx4j

    parameters.put("types", ArrayUtils.toString(keys));
final Document partDOM = marshaltoW3CDomDocument(part.getJaxbElement());
final JAXBResult result = prepareJAXBResult(Context.jc);
    part.setJaxbElement(result);
origin: plutext/docx4j

/**
 * See your content as XML.  An easy way to invoke XmlUtils.marshaltoString 
 *  
 * @return
 * @since 3.0.0
 */
public String getXML() {
  return XmlUtils.marshaltoString( getJaxbElement(), true, true, jc );
}
 
origin: plutext/docx4j

String mceIgnorable = ((JaxbXmlPart)part).getMceIgnorable(); 
  w3cDoc = marshaltoW3CDomDocument(jaxbXmlPart.getJaxbElement(), 
      jaxbXmlPart.getJAXBContext(), mceIgnorable + jaxbXmlPart.getMcChoiceNamespaces());
origin: plutext/docx4j

  part.getJaxbElement() ); 	
    part.getPackage().getCustomXmlDataStorageParts());			
transformParameters.put("wmlPackage", wordMLPackage);			
transformParameters.put("sourcePart", part);			
    part.setJaxbElement(
        unmarshal(((org.w3c.dom.Document)result.getNode()),
        Docx4jProperties.getProperty("docx4j.model.datastorage.BindingTraverserXSLT.ValidationEventContinue", 
origin: plutext/docx4j

partStore = this.getPackage().getSourcePartStore();
String name = this.getPartName().getName();
InputStream is = partStore.loadPart( 
    name.substring(1));
ByteArray byteArray = ((ZipPartStore)partStore).getByteArray(this.getPartName().getName().substring(1));
byteArray.setBytes(saxHandler.getOutputStream().toByteArray());
  log.debug("unmarshalling");
jaxbElement = this.unmarshal( new ByteArrayInputStream(saxHandler.getOutputStream().toByteArray()) );  // so much for avoiding JAXB!
origin: plutext/docx4j

  part.getJaxbElement() ); 	
    part.getPackage().getCustomXmlDataStorageParts());			
transformParameters.put("wmlPackage", (WordprocessingMLPackage)pkg);			
transformParameters.put("sourcePart", part);			
origin: plutext/docx4j

if (jaxbElement==null) {
  PartStore partStore = this.getPackage().getSourcePartStore();
  String name = this.getPartName().getName();
  InputStream is = partStore.loadPart( 
      name.substring(1));
origin: plutext/docx4j

getContents();
setMceIgnorable( (McIgnorableNamespaceDeclarator) namespacePrefixMapper);
origin: plutext/docx4j

PartStore partStore = this.getPackage().getSourcePartStore();
String name = this.getPartName().getName();
InputStream is = partStore.loadPart( 
    name.substring(1));
org.w3c.dom.Document doc = org.docx4j.XmlUtils.neww3cDomDocument();            
try {
  this.marshal(doc);
} catch (JAXBException e) {
origin: plutext/docx4j

/**
 * Get the live contents of this part.
 * (getContents() is preferred, this is the older/less friendly method name)
 * @return
 */
public E getJaxbElement() {
  try {
    return getContents();
  } catch (Docx4JException e) {
    log.error(e.getMessage(), e);
    return null;
  } 
}
origin: plutext/docx4j

    getNewPartName("/chunk", ".xml", sourcePart.getRelationshipsPart()));
Relationship altChunkRel =sourcePart.addTargetPart(afiPart);
origin: plutext/docx4j

private void process(JaxbXmlPart part) throws Docx4JException {
  log.info("/n Processing " + part.getPartName().getName() );
    = part.getPackage();		
      part.getJaxbElement() ); 	
      part.setJaxbElement(result);
        part.setJaxbElement(o);
      } else 
        part.setJaxbElement(o);
origin: plutext/docx4j

  /**
   * Convert any w:fldSimple in this part to complex field. 
   * @param part
   * @throws Docx4JException
   */
  public static void complexifyFields(JaxbXmlPart part) throws Docx4JException {
    
    org.w3c.dom.Document doc = XmlUtils.marshaltoW3CDomDocument(
        part.getJaxbElement() ); 	
    
//        XPathsPart xPathsPart = null;
        
    JAXBContext jc = Context.jc;
    try {
      // Use constructor which takes Unmarshaller, rather than JAXBContext,
      // so we can set JaxbValidationEventHandler
      Unmarshaller u = jc.createUnmarshaller();
      u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler());
      javax.xml.bind.util.JAXBResult result = new javax.xml.bind.util.JAXBResult(u );
                
      org.docx4j.XmlUtils.transform(doc, xslt, null, result);
      
      part.setJaxbElement(result);
    } catch (Exception e) {
      throw new Docx4JException("Problems transforming fields", e);			
    }
        
  }
   
origin: plutext/docx4j

public void detectDmlVml(JaxbXmlPart p) {
  
  log.info("\n\n Inspecting " + p.getPartName().getName());
  
  dmlVmlAnalyzer.reinit();
  dmlVmlAnalyzer.setPart(p);
  new TraversalUtil(p.getJaxbElement(), dmlVmlAnalyzer);
  
  result.unsafeObjectsByPart.put(p, dmlVmlAnalyzer.unsafeObjects);
  if (dmlVmlAnalyzer.unsafeObjects.size()>0){
    result.anyUnsafeObjects = true;
  }
  result.inventoryObjectsByPart.put(p, dmlVmlAnalyzer.inventoryObjects);
  
  if (!result.containsVML) {
    result.containsVML = dmlVmlAnalyzer.containsVML;
  }
  
  result.fieldsPresent = this.dmlVmlAnalyzer.fieldsPresent;
  
}
 
org.docx4j.openpackaging.partsJaxbXmlPart

Javadoc

OPC Parts are either XML, or binary (or text) documents. Most are XML documents. docx4j aims to represent XML parts using JAXB. Any XML Part for which we have a JAXB representation (eg the main document part) should extend this Part. This class provides only one of the methods for serializing (marshalling) the Java content tree back into XML data found in javax.xml.bind.Marshaller interface. You can always use any of the others by getting the jaxbElement required by those methods. Insofar as unmarshalling is concerned, at present it doesn't contain all the methods in javax.xml.bind.unmarshaller interface. This is because the content always comes from the same place (ie from a zip file or JCR via org.docx4j.io.*). TODO - what is the best thing to unmarshall from?

Most used methods

  • getJaxbElement
    Get the live contents of this part. (getContents() is preferred, this is the older/less friendly met
  • getContents
    Get the live contents of this part (the JAXB object model). (An alias/synonym for older getJaxbEleme
  • addMcChoiceNamespace
  • addTargetPart
  • getContentLengthAsLoaded
  • getJAXBContext
  • getMcChoiceNamespaces
  • getMceIgnorable
  • getPackage
  • getPartName
  • getRelationshipsPart
  • getXML
    See your content as XML. An easy way to invoke XmlUtils.marshaltoString
  • getRelationshipsPart,
  • getXML,
  • isUnmarshalled,
  • marshal,
  • pipe,
  • remove,
  • setContentLengthAsLoaded,
  • setJAXBContext,
  • setJaxbElement,
  • setMceIgnorable

Popular in Java

  • Start an intent from android
  • findViewById (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now