Approach for transforming XML document to and from data objects in an object oriented framework for content management applications6785685Abstract A method and system for transforming XML documents to and from data objects in an object oriented framework includes: importing the XML document; parsing the XML document; building a DOM tree from the parsed XML document; constructing at least one DDO or at least one XDO based on the DOM tree; and storing the DDO or XDO in a datastore. The present invention provides a transformation bridge connecting the XML world and the object world, allowing conversions from XML documents to data objects and vice versa to be performed seamlessly. It enhances the existing framework with a feature to process XML documents utilizing the existing framework facilities. Application developers can thus exploit the key advantages of XML representation as well as object orientation. Claims What is claimed is: Description FIELD OF THE INVENTION
/**
* Creates a new DKDDO object using the given XML input file.
* All references to binary data (blob or xdo) will be resolved and
brought into
* memory.
*
* @param xmlSource is a DLNVPair class specifying the XML source
* characteristics, with the following possible values:
* <ul>
* <li> ("BUFFER", <buffer_ref>) : buffer_ref is a reference
to a string in
* memory
* <li> ("FILE", <file_name>) : string file_name is the name
of the file
* containing the XML
* <li> ("URL", <url_address>) : string URL-address location
of the XML
* <li> ("STDIN", null) : input XML is taken from standard input
* (STDIN)
* </eul>
* @param options options to govern the construction of xdo classes, if
exists in the
* XML input
* Valid values are specified by constants in DKConstant.java:
* public static int DK_CM_XDO_EMBED = 0;
* retrieve any reference to blobs into memory
* public static int DK_CM_XDO_REFERENCE =1;
* do not retrieve any reference to xdo, i.e. in form of file reference
or URL,
* into memory, but delay it until the value is needed. If the value is
needed
* for an add operation, i.e. to make it persistent, then it will try to
optimize
* the operation via xdo.add(fromFile) whenever possible.
*/
public DKDDO(DKNVPair xmlSource, int options);
public DKDDO(DKNVPair xmlSource);
In the preferred embodiment, the DTD file 312 is as follows:
<!ELEMENT ddo:ddo (ddo:pid, ddo:propertyCount?, ddo:property*,
ddo:dataCount?, ddo:dataItem*)>
<!ATTLIST ddo:pid ddo:dsType CDATA #IMPLIED
ddo:dsName CDATA #IMPLIED
ddo:pidString CDATA #IMPLIED>
<!ELEMENT ddo:propertyCount (#PCDATA)?
<!ELEMENT ddo:property EMPTY>
<!ATTLIST ddo:property ddo:propertyID CDATA #IMPLIED
ddo:propertyName CDATA #IMPLIED.backslash.
ddo:propertyValue CDATA #IMPLIED?
<!ELEMENT ddo:dataCount (#PCDATA)>
<!ELEMENT ddo:dataItem (ddo:dataPropertyCount?,
ddo:dataProperty+,
(ddo:dataValue .vertline.
ddo:dataValues)
)>
<!ATTLIST ddo:dataItem ddo:dataID CDATA #IMPLIED
ddo:dataName CDATA #IMPLIED>
<!ELEMENT ddo:dataValues (ddo:dataValueCount?, ddo:dataValue+)>
<!ELEMENT ddo:dataValueCount (#PCDATA)>
<!ELEMENT ddo:dataValue (#PCDATA .vertline. ddo:xdoRef .vertline.
ddo:ddo)>
<!ELEMENT ddo:xdoRef (ddo:xdoPid, ddo:xdoValue)>
<!ELEMENT ddo:xdoPid EMPTY>
<!ATTLIST ddo:xdoPid ddo:dsType CDATA #REQUIRED
ddo:dsName CDATA #REQUIRED
ddo:xdoType CDATA #REQUIRED
ddo:partId CDATA #REQUIRED
ddo:repType CDATA #REQUIRED
ddo:pidString CDATA #REQUIRED
<!ELEMENT ddo:xdoValue (ddo:contentType?, ddo:searchEngineInfo?,
ddo:smsInfo?, ddo:xdoContent?)>
<!ATTLIST ddo:xdoValue
ddo:refType CDATA #REQUIRED
ddo:refEncoding CDATA #IMPLIED
ddo:mimeType CDATA #REQUIRED
XML-LINK CDATA #IMPLIED
HREF CDATA #IMPLIED
<!ELEMENT ddo:contentType (#PCDATA)>
<!ELEMENT ddo:searchEngineInfo EMPTY>
<!ATTLIST ddo:searchEngineInfo ddo:searchEngine CDATA #REQUIRED
ddo:searchIndex CDATA #REQUIRED
ddo:searchInfo CDATA #REQUIRED>
<!ELEMENT ddo:smsInfo EMPTY>
<!ATTLIST ddo:smsInfo ddo:smsRetention CDATA #IMPLIED
ddo:smsCollection CDATA #IMPLIED
ddo:smsMgmtClass CDATA #IMPLIED
ddo:smsStorageClass CDATA #IMPLIED
ddo:smsObjServer CDATA #IMPLIED
<!ELEMENT ddo:xdoContent (#PCDATA)>
FIG. 4 is a process flow chart illustrating a preferred embodiment of exporting an XML documents from a data object in the object oriented framework in accordance with the present invention. First, the DDO's or XDO's are retrieved from the content manager datastore 212, via step 402, using the .retrieve( ) methods of the DDO class 204. The DDO or XDO is retrieved from persistent store into memory. The toXML( ) method 208 is then called. The EIP OO APIs 404 query the properties of the DDO's or XDO's in memory, via step 404a, and generate data files 412 on the local file system from any referenced XDO objects that are in memory, via step 404b. The properties of the DDO's or XDO's include the attributes of the object and the properties of the object itself. Approximately simultaneously, the parser's APIs 406 build a DOM tree based on the properties of the DOD's or XDO's, via step 406a. In the preferred embodiment, the DOM tree is built on the fly and in memory. The toXML( ) method 208 then serializes the DOM tree, via step 408, by producing the desired format based on the options for the output XML document 410. Options include whether to embed the XDO values in the XML document 410 or have a reference in the XML document 410 to data files 412 which contain the values. The XML document 410 results. In the preferred embodiment, the export function is implemented with the following Java code:
/**
* Generates the corresponding XML from this DKDDO. If the DDO is a nested
* object, it assumes that the DDO has been instantiated/retrieved up to
the desired
* level of depth.
* @param xmlDestination specifies where the XML output should go, valid
values
* are:
* <ul>
* <li> ("BUFFER", <buffer_ref>) : buffer_ref is a
reference to a string in memory
* <li> ("FILE", <file_name>) : string file_name is the
name of the file to
* contain the XML
* <li> ("URL", <url_address>) : string URL-address
location for the XML
* <li> ("STDOUT", null) : output XML is directed to the
standard
* output (STDOUT)
* </eul>
* @param options same as options described in the constructor above.
* DK_CM_XDO_EMBED means to embed the xdo value in the generated XML,
* either in plain text form (#PCDATA) or in Base64 encoding.
* DK_CM_XDO_REFERENCE means that you want to represent any blob with
a
* reference to a file or URL, in which the file or URL will be
created by
* writing the xdo content out to it.
* Both options above are mutually exclusive.
* The following option is complementary to the above:
* DK_CM_XDO_RETRIEVE means that in addition of either one of the two
* options above, if the xdo content is not retrieved then it will
be retrieved. If
* the destination is file, URL, or STDOUT, the implementation may
want to
* optimize the content transfer directly to the destination,
without storing
* intermediate copy in main memory.
* Note: If destination is memory BUFFER or STDOUT and the path is not
null and
* the options is REFERENCE, then a reference form to the xdo will be
created as
* described above.
public void toXML (DKNVPair xmlDestination, String path, long options);
For example, assume that a simple DDO contains two attributes: (1) name="Title", value="How to marry a millionaire"; (2) name="Author", value="Dr. Ruth Wildheimer". Assume also that this DDO has been stored in persistent store in the content manager datastore 212. This DDO can be retrieved and the toXML( ) method 208 called, resulting in an XML document 410 approximately like the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ddo:ddo SYSTEM "ddo.dtd">
<ddo:ddo ddo:entityName="DLSAMPLE"
xmlns=http://www.omg.org/pub/docs/formal/97-12-12.p-df#ddo/EIP-7.1>
<pid dsType="DL" dsName="LIBARNEY"
pidString="44 2 DL8 LIBARNEY8 DLSAMPLE19 16 FKX$S0A9PPGZSS41"/>
<propertyCount>1</propertyCount>
<property propertyId="1" propertyName="item-type"
propertyValue="document" />
<!--or folder, etc.-->
<dataCount>2</dataCount>
<dataItem dataId="1" dataName="Title">
<dataProperty propertyId="1" propertyName="type"
propertyValue="string"/>
<dataProperty propertyID="2" propertyName="nullable"
propertyValue="true"/>
<dataValue>How to marry a millionaire</dataValue>
</dataItem>
<dataItem dataId="2" dataName="Author">
<dataProperty propertyId="1" propertyName="type"
propertyValue="string"/>
<dataProperty propertyId="2" propertyName="nullable"
propertyValue="false"/>
<dataValue>Dr. Ruth Wildheimer</dataValue>
</dataItem>
</ddo:ddo>
In the preferred embodiment, there are four different ways to import and export an XDO or blobs from and into the resulting XML document: (1) embedding, (2) reference to a file, (3) reference to a URL, or (4) using PidString. These four approaches are first discussed for the exporting of an XDO or blob. Per embedding the blob content in the XML document 410, if the blob contains binary-data, it is converted to Base64 encoding before embedding it in the XML document 410. If the data is of type plain text, then encoding is not necessary. In this case, the encoding is set to plain-text. The advantage of this approach is that since the blob content is packaged together with the XML, the document will be self contained. Per referencing a file, the blob content is written out into a local file or network file system 412. A reference is established to the file system. This approach assumes that the process which will import the XML has access to the same file systems. Either directory path and file name or a URL notation can be used to specify the reference, for example: file://c:/picture.gif. Per referencing a URL, the blob content is written into a web server directory, and a reference is established to the directory. This approach assumes that a web server exists, and the process which will import the XML has access to the web server to retrieve the content. Per using PidString, PidString is a persistent identifier defined in the OMG standard. It is mechanism used to find particular items in a datastore. Once a PidString is created for an item, it can be stored within the DDO or the XDO and reused. The PidString created for the blob content can be used to retrieve the blob content. The four approaches are next discussed for the importing of XDOs or blobs. Per embedding the blob content in the XML document 302, if the content is embedded using Base64 encoding, it will be decoded by a Base 64 decoder. If the content is plain-text, it will be read in directly. Per referencing a file, there are two possibilities. First, the blob content is read in immediately to main memory. Second, if the blob content is stored in a file, then the XDO should make a note of it. When the add operation is called, the blob content will be transferred directly to the persistent store. In this approach, the XDO class is modified to handle this delayed content read. Per referencing a URL, during the add operation, the blob content will be retrieved from the web server and transferred directly to the persistent store. Per using PidString, the URL string will be parsed to extract the PidString and the object type. Based on this information, the proper blob object and its Pid can be created. The same approaches may be used when importing or exporting collections of DDO's or XDO's. The XML segments imported into the framework 200 or exported from the framework 200 can comprise representations for single-valued data-items, representations for multi-valued data-items, a reference to a single XDO whose value is embedded into the XML document, a reference to a single XDO whose value is in a file, a reference to a single DDO, a reference to a collection of XDO's, a reference to a collection of DDO's, and/or a self reference to the source XML document to be stored as an XDO. Examples of each of these are as follows: The following is an example of an XML segment with representations for single-valued data-items:
<dataItem dataId=1" dataName="Author"/>
<dataPropertyCount>2</dataPropertyCount>
<dataProperty propertyId="1" propertyName="type" propertyValue=
"string"/>
<dataProperty propertyId="2" propertyName="nullable"
propertyValue="false"/>
<dataValue>Dr. Ruth Wildheimer</dataValue>
</dataItem>
The following is an example of an XML segment with representations for multi-valued data-items:
<dataItem dataId="1" dataName="Authors"/>
<dataPropertyCount>2</dataPropertyCount>
<dataProperty propertyId="1" propertyName="type"
propertyValue="collection+string"/>
<dataValues>
<dataValueCount>2</dataValueCount>
<dataValue>Dr. Ruth Wildheimer</dataValue>
<dataValue>Ivonna Trump</dataValue>
</dataValues>
</dataItem>
The following are examples of XML segments with a reference to a single XDO. The value of the XDO can either be embedded inside the XML document or can be in a file. The following is an example of a XML segment with a reference to a single XDO when the value of the XDO is embedded inside the XML segment:
<dataItem dataId="1" dataName="Employee_Photo"/>
<dataPropertyCount>2</dataPropertyCount>
<dataPropertyId="1" propertyName="type" propertyValue="xdo"/>
<dataProperty propertyId="2" propertyName-"nullable"
propertyValue="true"/>
<dataValue>
<xdoRef>
<xdoPid dsType="DL" xdoType="DKBlobDL"/>
<xdoValue refType="embed"
refEncoding="Base64"
mimeType="image/bmp">
<contentType>WINV3BM</contentType>
<searchEngineInfo searchEngine="SM" searchIndex=
"TMINDEX"
searchInfo="ENU"/>
<smsInfo collection="CBR.CLLCT001"/>
<!--following is XDO binary content, embedded in
Base64 encoding -->
<xdoContent>
aBcYp12....a.very.long..content..encoded.in.
Base64....etc
</xdoContent>
</xdoValue>
</xdoRef>
</dataValue>
<dataItem>
The following is an example of a XML segment with a reference to a single XDO when the value of the XDO is in a file:
<dataItem dataId="2" dataName="Employee_Resume"/>
<dataPropertyCount>2</dataPropertyCount>
<dataPropertyId="1" propertyName="type" propertyValue="xdo"/>
<dataProperty propertyId="2" propertyName-"nullable"
propertyValue="true"/>
<dataValue>
<xdoRef>
<xdoPid dsType="DL" xdoType="DKBlobDL"/>
<xdoValue refType="file"
mimeType="text/plain"
XML-LINK="SIMPLE"
HREF="C:.backslash.userarea.backslash.tmp.backslash.resume.txt">
<contentType>ASCII</contentType>
<searchEngineInfo searchEngine="SM" searchIndex=
"TMINDEX"
searchInfo="ENU"/>
<smsInfo collection="CBR.CLLCT001"/>
</xdoValue>
</xdoRef>
</dataValue>
<dataItem>
The following is an example of a XML segment with a reference to a single DDO:
<dataItem dataId="1" dataName="InvoiceRecord"/>
<dataProperty propertyId="1" propertyName-"type" propertyValue-
"ddo"/>
<dataProperty propertyId="2" propertyName="nullable"
propertyValue="false"/>
<dataValue>
<ddo entityName="Invoice">
<pid .../>
<propertyCount> ...
<property ...>
<dataItem ...>
<!-- ...etc....this structure can be nested -->
</ddo>
</dataValue>
</dataItem>
The following is an example of a XML segment with a reference to a collection of XDO's:
<dataItem dataId="3" dataName="DKParts"/>
<dataPropertyCount>2</dataPropertyCount>
<dataProperty propertyID="1" propertyName="type"
propertyValue="collection+xdo"/>
<dataProperty propertyId="2" propertyName-"nullable"
propertyValue-"true"/>
<dataValues>
<dataValueCount>2</dataValueCount>
<dataValue>
<xdoPid dsType-"DL" xdoType-"DKBlobDL" partId-"1"
repType-"FRN$NULL"/>
<xdoValue refType="embed"
refEncoding="Base64"
mimeType="image/bmp">
<contentType>WINV3BM</contentType>
<searchEngineInfo searchEngine="SM" searchIndex=
"TMINDEX"
searchInfo="ENU"/>
<smsInfo collection="CBR>CLLCT001"/>
<!--following is XDO binary content,
embedded in Base 64 encoding
-->
<xdoContent>
aBcYp12....a.very.long..content..encoded.in.
Base64....etc
</xdoContent>
</xdoValue>
</xdoRef>
</dataValue>
<dataValue>
<xdoRef>
<xdoPid dsType="DL" xdoType=
"DKBlobDL" partId="1"/>
<xdoValue refType="file"
mimeType="text/plain"
XML-LINK="SIMPLE"
HREF="c:.backslash.userarea.backslash.tmp.backslash.resume.text">
<contentType>ASCII</contentType>
<searchEngineInfo searchEngine="SM" searchIndex=
"TMINDEX"
searchInfo="ENU"/>
<smsInfo collection="CBR>CLLCT001"/>
</xdoValue>
</xdoRef>
</dataValue>
</dataValues>
</dataItem>
The following is an example of a XML segment with a reference to a collection of DDO's:
<dataItem dataId="5" dataName="DKFolder"/.
<dataPropertyCount>2</dataPropertyCount?
<dataProperty propertyId="1" propertyName="type"
propertyValue="collection+ddo"/>
<dataProperty propertyId="2" propertyName="nullable"
propertyValue="false"/>
<dataValues>
<dataValueCount>2</dataValueCount>
<dataValue>
<ddo entityName="DLSAMPLE">
<pid .../>
<propertyCount> ...
<property ...>
<dataItem ...>
<!...etc....this structure can be nested -->
</ddo>
<ddo entityName="DLSAMPLE">
<pid .../>
<propertyCount> ...
<property ...>
<dataItem ...>
<!-- ...etc....this structure can be nested
-->
</ddo>
</dataValue>
</dataValues>
</dataItem>
The following is an example of a XML segment with a self reference to the source XML document to be stored as an XDO. This self reference is useful for including the original XML source in the DDO to be constructed during the import process, either as an individual part or as a part in a collection. The preferred embodiment captures the current XML source and sets it as the content of the newly created XDO object:
...
<xdoRef>
<xdoPid dsType="DL" xdoType="DKBlobDL"/>
<xdoValue refType="self"
mimeType="text/xml">
<contentType>XML</contentType>
<searchEngineInfo searchEngine="sm" searchIndex=
"TMINDEX"
searchInfo="ENU"/>
<smsInfo collection="CBR.CLLCT001"/>
</xdoValue>
</xdoRef>
A method and system for transforming XML documents to and from data objects in an object oriented framework has been disclosed. The present invention provides a transformation bridge connecting the XML world and the object world, allowing conversions from XML documents to data objects and vice versa to be performed seamlessly. It enhances the existing framework with a feature to process XML documents utilizing the existing framework facilities. Application developers can thus exploit the key advantages of XML representation as well as object orientation. Although the present invention has been described in accordance with the embodiments shown, one of ordinary skill in the art will readily recognize that there could be variations to the embodiments and those variations would be within the spirit and scope of the present invention. Accordingly, many modifications may be made by one of ordinary skill in the art without departing from the spirit and scope of the appended claims.
|
Same subclass Same class Consider this |
||||||||||
