IP*Works! ZIP V8

ipworkszip
Class Officedoc

java.lang.Object
  |
  +--ipworkszip.Officedoc

public class Officedoc
extends java.lang.Object

The OfficeDoc bean implements support for the Open XML Packaging Format used in Office 2007 documents.

The bean provides a way to extract information and content from an Open XML packaged document, examine the package properties and basic read/update facilities.


Constructor Summary
Officedoc()
           
 
Method Summary
 void addOfficedocEventListener(ipworkszip.OfficedocEventListener l)
           
 void close()
          Closes the Open XML package archive
 java.lang.String config(java.lang.String configurationString)
          Sets or retrieves a configuration setting.
 void extractPart()
          Reads the contents of the currently selected part.
 java.lang.String findPartByType(java.lang.String typeURI)
          Looks up a part in the current relationships file by it's type namespace URI
 ipworkszip.ContentTypeList getContentTypes()
          Collection of content type entries
 ipworkszip.XMLNamespaceList getNamespaces()
          Collection of namespaces in the current namespace stack.
 java.lang.String getPackagePath()
          The path to the Open XML package file
 ipworkszip.PackagePropertyList getPackageProperties()
          Collection of core/app/custom metadata properties associated with the archive.
 byte[] getPartData()
          The contents of the currently selected part.
 java.lang.String getPartName()
          The name of the currently selected part
 java.lang.String getPropertyValue(java.lang.String propName, java.lang.String propNamespace)
          Returns the value of the specified package property.
 ipworkszip.RelationshipList getRelationships()
          Collection of Relationships in the current relationships (*.rels) file
 ipworkszip.XMLAttributeList getXAttributes()
          A collection of attributes of the current element.
 ipworkszip.XMLElementList getXChildren()
          Collection of child elements of the current element.
 java.lang.String getXElement()
          The name of the current element.
 java.lang.String getXNamespace()
          The namespace of the current element.
 java.lang.String getXParent()
          The parent of the current element.
 java.lang.String getXPath()
          Provides a way to point to a specific element in the document.
 java.lang.String getXPrefix()
          The prefix of the current element.
 java.lang.String getXSubTree()
          A snapshot of the current element in the document.
 java.lang.String getXText()
          The text of the current element.
 boolean isValidate()
          When True, the parser checks that the document consists of well-formed XML.
 void listParts()
          List all the parts contained in the document and their relationships.
 void open()
          Opens the Open XML package archive
 void parsePart()
          Parses the specified part as XML.
 void readRelationships()
          Reads the relationships file in the archive associated with the specified part
 void removeOfficedocEventListener(ipworkszip.OfficedocEventListener l)
           
 void replacePart()
          Replaces the contents of the specified part in the package.
 java.lang.String resolveContentType()
          Returns the content type of the specified part.
 void setPackagePath(java.lang.String packagePath)
          The path to the Open XML package file
 void setPartData(byte[] partData)
          The contents of the currently selected part.
 void setPartName(java.lang.String partName)
          The name of the currently selected part
 void setValidate(boolean validate)
          When True, the parser checks that the document consists of well-formed XML.
 void setXPath(java.lang.String XPath)
          Provides a way to point to a specific element in the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Officedoc

public Officedoc()
Method Detail

getContentTypes

public ipworkszip.ContentTypeList getContentTypes()
Collection of content type entries

Contains the default content types, as well as overrides for parts in the archive.


getNamespaces

public ipworkszip.XMLNamespaceList getNamespaces()
Collection of namespaces in the current namespace stack.

This property contains a collection of XML namespaces, which are standards for providing uniquely named elements and attributes in an XML instance.

This collection is indexed from 0 to size - 1.


getPackagePath

public java.lang.String getPackagePath()
The path to the Open XML package file

This property specifies the path and filename of the Open XML package to work on.


setPackagePath

public void setPackagePath(java.lang.String packagePath)
                    throws IPWorksZipException
The path to the Open XML package file

This property specifies the path and filename of the Open XML package to work on.

IPWorksZipException

getPackageProperties

public ipworkszip.PackagePropertyList getPackageProperties()
Collection of core/app/custom metadata properties associated with the archive.

When the package is first opened using Open , the bean looks for any metadata property files in the archive and will expose their contents through this collection.


getPartData

public byte[] getPartData()
The contents of the currently selected part.

This property will hold the contents of the part selected by PartName after calling the ExtractPart method. It can also be set before calling ReplacePart .


setPartData

public void setPartData(byte[] partData)
                 throws IPWorksZipException
The contents of the currently selected part.

This property will hold the contents of the part selected by PartName after calling the ExtractPart method. It can also be set before calling ReplacePart .

IPWorksZipException

getPartName

public java.lang.String getPartName()
The name of the currently selected part

This property specifies the name of the currently selected part in the document. If null or empty, no part is currently selected.


setPartName

public void setPartName(java.lang.String partName)
                 throws IPWorksZipException
The name of the currently selected part

This property specifies the name of the currently selected part in the document. If null or empty, no part is currently selected.

IPWorksZipException

getRelationships

public ipworkszip.RelationshipList getRelationships()
Collection of Relationships in the current relationships (*.rels) file

When the package is first opened using Open , the top-level relationships file (/rels/.rels) is parsed and this collection populated with its contents. The ReadRelationships method can be used to populate this collection with the contents of other, part-specific relationship files, as needed.


isValidate

public boolean isValidate()
When True, the parser checks that the document consists of well-formed XML.

You can set Validate to False when you want to ignore XML format rules (e.g. while parsing HTML files).


setValidate

public void setValidate(boolean validate)
                 throws IPWorksZipException
When True, the parser checks that the document consists of well-formed XML.

You can set Validate to False when you want to ignore XML format rules (e.g. while parsing HTML files).

IPWorksZipException

getXAttributes

public ipworkszip.XMLAttributeList getXAttributes()
A collection of attributes of the current element.

This collection consists of all attributes of the current XML element. The component parses each attribute into a collection of xmlattribute types.

This collection is indexed from 0 to size - 1.


getXChildren

public ipworkszip.XMLElementList getXChildren()
Collection of child elements of the current element.

The elements are provided in the collection in the same order they are found in the document.

This collection is indexed from 0 to size - 1.


getXElement

public java.lang.String getXElement()
The name of the current element.

The current element is specified via the XPath property.


getXNamespace

public java.lang.String getXNamespace()
The namespace of the current element.

The current element is specified via the XPath property.


getXParent

public java.lang.String getXParent()
The parent of the current element.

The current element is specified via the XPath property.


getXPath

public java.lang.String getXPath()
Provides a way to point to a specific element in the document.

XPath implements a subset of the XML XPath specification, allowing you to point to specific elements in the XML documents.

The path is a series of one or more element accessors separated by '/'. The path can be absolute (starting with '/') or relative to the current XPath location.

The following are possible values for an element accessor:

'name'
A particular element name
name[i]
The i-th subelement of the current element with the given name
[i]
The i-th subelement of the current element
[last()]
The last subelement of the current element
[last()-i]
The subelement located at the last location minus i in the current element
name[@attrname="attrvalue"]
The subelement containing a particular value for a given attribute (supports single AND double quotes)
..
The parent of the current element
When XPath is set to a valid path, XElement points to the name of the element, with XParent , XNamespace , XPrefix , XChildren , and XText providing other properties of the element. The attributes of the current element are provided in the XAttributes collection .

BuildDOM must be set to True prior to parsing the document for the XPath functionality to be available. Example (Setting XPath)

 
 
Document root
XMLpControl.XPath = "/"
Specific Element
XMLpControl.XPath = "/root/SubElement1/SubElement2/"
i-th Child
XMLpControl.XPath = "/root/SubElement1[i]"


setXPath

public void setXPath(java.lang.String XPath)
              throws IPWorksZipException
Provides a way to point to a specific element in the document.

XPath implements a subset of the XML XPath specification, allowing you to point to specific elements in the XML documents.

The path is a series of one or more element accessors separated by '/'. The path can be absolute (starting with '/') or relative to the current XPath location.

The following are possible values for an element accessor:

'name'
A particular element name
name[i]
The i-th subelement of the current element with the given name
[i]
The i-th subelement of the current element
[last()]
The last subelement of the current element
[last()-i]
The subelement located at the last location minus i in the current element
name[@attrname="attrvalue"]
The subelement containing a particular value for a given attribute (supports single AND double quotes)
..
The parent of the current element
When XPath is set to a valid path, XElement points to the name of the element, with XParent , XNamespace , XPrefix , XChildren , and XText providing other properties of the element. The attributes of the current element are provided in the XAttributes collection .

BuildDOM must be set to True prior to parsing the document for the XPath functionality to be available. Example (Setting XPath)

 
 
Document root
XMLpControl.XPath = "/"
Specific Element
XMLpControl.XPath = "/root/SubElement1/SubElement2/"
i-th Child
XMLpControl.XPath = "/root/SubElement1[i]"

IPWorksZipException

getXPrefix

public java.lang.String getXPrefix()
The prefix of the current element.

The current element is specified via the XPath property.


getXSubTree

public java.lang.String getXSubTree()
A snapshot of the current element in the document.

The current element is specified via the XPath property. In order for this property to work you must have the CacheContent set to true.


getXText

public java.lang.String getXText()
The text of the current element.

The current element is specified via the XPath property.


close

public void close()
           throws IPWorksZipException
Closes the Open XML package archive

When this method is called, the bean will close the current archive and release all resources.

IPWorksZipException

config

public java.lang.String config(java.lang.String configurationString)
                        throws IPWorksZipException
Sets or retrieves a configuration setting.

Config is a generic method available in every bean. It is used to set and retrieve configuration settings for the bean.

Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.

The bean accepts one or more of the following configuration settings . Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the Config method.

OfficeDoc Configuration Settings

Base Configuration Settings

GUIAvailable
Tells the bean whether or not a message loop is available for processing events
In a GUI-based application, long-running blocking operations may cause the application to stop responding to input until the operation returns. The bean will attempt to discover whether or not the application has a message loop and, if one is discovered, it will process events in that message loop during any such blocking operation.In some non-GUI applications an invalid message loop may be discovered that will result in errant behavior. In these cases, setting GuiAvailable to false will ensure that the bean does not attempt to process external events.

IPWorksZipException

extractPart

public void extractPart()
                 throws IPWorksZipException
Reads the contents of the currently selected part.

If the part specified by the PartName property exists, the corresponding physical file will be extracted from the archive and will be available through the PartData property.

If the part doesn't exists, or it's stored in interleaved format, an error will be raised.

IPWorksZipException

findPartByType

public java.lang.String findPartByType(java.lang.String typeURI)
                                throws IPWorksZipException
Looks up a part in the current relationships file by it's type namespace URI

If a matching part can be found, it's part name is returned. Otherwise, an empty string is returned.

IPWorksZipException

getPropertyValue

public java.lang.String getPropertyValue(java.lang.String propName,
                                         java.lang.String propNamespace)
                                  throws IPWorksZipException
Returns the value of the specified package property.

Looks up a package property named PropName in namespace PropNamespace in the core and app properties tables and returns it's value, if found.

If the property doesn't exists, an empty string is returned.

For custom properties. use an empty string ("") as the value of the PropNamespace parameter.

IPWorksZipException

listParts

public void listParts()
               throws IPWorksZipException
List all the parts contained in the document and their relationships.

When this method is called, the bean will read all the relationships in the document, recursively, and populate the Relationships collection.

IPWorksZipException

open

public void open()
          throws IPWorksZipException
Opens the Open XML package archive

When this method is called, the bean will attempt to open the archive specified in PackagePath and extract package properties, content types and parse the master relationships file in the archive.

IPWorksZipException

parsePart

public void parsePart()
               throws IPWorksZipException
Parses the specified part as XML.

If the part specified by PartName exists, the corresponding physical file will be extracted from the archive and parsed as XML. If BuildDOM is enabled, the DOM will be built internally and you can use XPath to query the resulting document, using the XPath property. If BuildDOM is disabled, only the XML parser-related events will be fired.

IPWorksZipException

readRelationships

public void readRelationships()
                       throws IPWorksZipException
Reads the relationships file in the archive associated with the specified part

When this method is called, the bean will look for a .rels file associated with the part specified by the PartName property. If found, the Relationships collection will now expose the contents of the relationships for that part.

IPWorksZipException

replacePart

public void replacePart()
                 throws IPWorksZipException
Replaces the contents of the specified part in the package.

If the part specified by the PartName property exists, the corresponding physical file will be replaced with the contents of the PartData property. The package file will be modified in place right away.

If the part doesn't exists, it's stored in interleaved format, or PartData is null or empty, an error will be raised.

IPWorksZipException

resolveContentType

public java.lang.String resolveContentType()
                                    throws IPWorksZipException
Returns the content type of the specified part.

Applies the content type resolution rules specified in the Open XML packaging specification and returns the content type associated with PartName in the archive.

If there's no content type mapped for the part or for the extension, an empty string is returned.

IPWorksZipException

addOfficedocEventListener

public void addOfficedocEventListener(ipworkszip.OfficedocEventListener l)
                               throws java.util.TooManyListenersException
java.util.TooManyListenersException

removeOfficedocEventListener

public void removeOfficedocEventListener(ipworkszip.OfficedocEventListener l)

IP*Works! ZIP V8

Copyright (c) 2011 /n software inc. - All rights reserved.