|
IP*Works! ZIP V8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ipworkszip.Officedoc
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 |
public Officedoc()
| Method Detail |
public ipworkszip.ContentTypeList getContentTypes()
Contains the default content types, as well as overrides for parts in the archive.
public ipworkszip.XMLNamespaceList getNamespaces()
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.
public java.lang.String getPackagePath()
This property specifies the path and filename of the Open XML package to work on.
public void setPackagePath(java.lang.String packagePath)
throws IPWorksZipException
This property specifies the path and filename of the Open XML package to work on.
IPWorksZipExceptionpublic ipworkszip.PackagePropertyList getPackageProperties()
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.
public byte[] getPartData()
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 .
public void setPartData(byte[] partData)
throws IPWorksZipException
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 .
IPWorksZipExceptionpublic java.lang.String getPartName()
This property specifies the name of the currently selected part in the document. If null or empty, no part is currently selected.
public void setPartName(java.lang.String partName)
throws IPWorksZipException
This property specifies the name of the currently selected part in the document. If null or empty, no part is currently selected.
IPWorksZipExceptionpublic ipworkszip.RelationshipList getRelationships()
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.
public boolean isValidate()
You can set Validate to False when you want to ignore
XML format rules (e.g. while parsing HTML files).
public void setValidate(boolean validate)
throws IPWorksZipException
You can set Validate to False when you want to ignore
XML format rules (e.g. while parsing HTML files).
IPWorksZipExceptionpublic ipworkszip.XMLAttributeList getXAttributes()
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.
public ipworkszip.XMLElementList getXChildren()
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.
public java.lang.String getXElement()
The current element is specified via the XPath property.
public java.lang.String getXNamespace()
The current element is specified via the XPath property.
public java.lang.String getXParent()
The current element is specified via the XPath property.
public java.lang.String getXPath()
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:
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]"
public void setXPath(java.lang.String XPath)
throws IPWorksZipException
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:
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]"
IPWorksZipExceptionpublic java.lang.String getXPrefix()
The current element is specified via the XPath property.
public java.lang.String getXSubTree()
The current element is specified via the XPath property. In order for this property to work you must have the CacheContent set to true.
public java.lang.String getXText()
The current element is specified via the XPath property.
public void close()
throws IPWorksZipException
When this method is called, the bean will close the current archive and release all resources.
IPWorksZipException
public java.lang.String config(java.lang.String configurationString)
throws IPWorksZipException
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.
IPWorksZipException
public void extractPart()
throws IPWorksZipException
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
public java.lang.String findPartByType(java.lang.String typeURI)
throws IPWorksZipException
If a matching part can be found, it's part name is returned. Otherwise, an empty string is returned.
IPWorksZipException
public java.lang.String getPropertyValue(java.lang.String propName,
java.lang.String propNamespace)
throws IPWorksZipException
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
public void listParts()
throws IPWorksZipException
When this method is called, the bean will read all the relationships in the document, recursively, and populate the Relationships collection.
IPWorksZipException
public void open()
throws IPWorksZipException
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
public void parsePart()
throws IPWorksZipException
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
public void readRelationships()
throws IPWorksZipException
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
public void replacePart()
throws IPWorksZipException
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
public java.lang.String resolveContentType()
throws IPWorksZipException
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
public void addOfficedocEventListener(ipworkszip.OfficedocEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removeOfficedocEventListener(ipworkszip.OfficedocEventListener l)
|
IP*Works! ZIP V8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||