Converting your old CMS database to XML format that can be imported into OpenCDS.

As we are currently working on migration from my company old CMS to OpenCDS so I have to migrate the old data from the old CMS database (MSSQL Server) to OpenCDS database (Oracle) and offcourse the two ERDs are completely different.
So the solution that I follow is to export the data from my old CMS to XML files then use XML_Submission to insert this data into OpenCDS and this will guarantee that the relation for each piece of content is created correctly.

I will discuess in this Article how to export the data from your old CMS database to XML files with format that can be imported into OpenCDS.

Mainly we have four classes and XSLT for each xml format.

The four classes are:

  1. AbstractXMLReader.java
  2. SqlInputSource.java
  3. SqlXMLReader.java
  4. TransformMaster.java (Main Class)
  • First I will speak about the four Java classes:

      in this classes I have used Echo.xsl to just generate XML file that is identical to the DOM created in the memory.
      then I will use Content.xsl to transform this file into multiple files that are ready for importing into OpenCDS using the following command
      java net.sf.saxon.Transform data/Content.xml xslt/Content.xsl
      Note:
      you have to create folder called transformed as I fixed this folder in the Content.xsl so that all generated XML will be placed in this folder.

      A better approche is to use Content.xsl inside the java code to transform directly form the DOM created into memory to multiple files that are ready to import into OpenCDS.

    1. AbstractXMLReader.java
    2. Which is an abstract class that implements the SAX2 XMLReader interface. The intent of this class is to make it easy for subclasses to act as SAX2 XMLReader implementations. This makes it possible, for example, for them to emit SAX2 events that can be fed into an XSLT processor for transformation.
      The code is attached.

    3. SqlInputSource.java
    4. Which is a class that extends InputSource.
      The intent of this class is to just holds a copy of the ResultSet object for the XML reader to use it.
      The code is attached.

    5. SqlXMLReader.java
    6. TransformMaster.java
    1. The following XSLT is responisble for generating XML that is valid for OpenCDS

      This XSLT are used to transform the generate XML files(one XML for each Record) and those XML are ready to be imported to OPenCDS from the DOM created in the memory by the Java Code above.

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:output method="text" media-type="text/xml" indent="yes" encoding="UTF-8" />
      <xsl:output method="xml" indent="yes" name="xml" encoding="UTF-8"/>

      <xsl:template match="/">
      <xsl:for-each select="/Content/ROW">
      <xsl:variable select="Content_Name" name="contentName" />
      <xsl:variable select="Content_File_ID" name="newfile" />
      Creating <xsl:value-of select="concat('transformed/', $newfile, '.xml')" />
      <xsl:result-document href="{concat('transformed/', $newfile, '.xml')}" >
      <![CDATA[<ContentSubmission>
      <Username>aabdelaziz</Username>
      <Password>aabdelaziz</Password>
      <Action value="New"/>
      <ContentDescriptor>
      <ContentType>]]><xsl:value-of select="Type_Name"/><![CDATA[</ContentType>]]>
      <![CDATA[<ContentURL src="http://10.10.10.72/ContentDBSite/Temp]]><xsl:value-of select="Content_URL"/><![CDATA["/>]]>
      <![CDATA[<EditionName>]]><xsl:value-of select="File_Name"/><![CDATA[</EditionName>]]>
      <![CDATA[<Version>1.0</Version>]]>
      <xsl:variable select="Wap_Preview" name="wapPreview" />
      <xsl:variable select="Web_Preview" name="webPreview" />
      <xsl:choose>
      <xsl:when test="($wapPreview != '' and $wapPreview != null) or ($webPreview != '' and $webPreview != null)">
      <![CDATA[<Preview>]]>
      <xsl:choose>
      <xsl:when test="$wapPreview = '' or $wapPreview = null">
      </xsl:when>
      <xsl:otherwise>
      <![CDATA[<Wap>]]>
      <xsl:for-each select="Wap_Preview"><![CDATA[<File caption="caption" src="http://10.10.10.72/ContentDBSite/Temp]]><xsl:value-of select="."/><![CDATA["/>]]></xsl:for-each>
      <![CDATA[</Wap>]]>
      </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
      <xsl:when test="$webPreview = '' or $webPreview = null ">
      </xsl:when>
      <xsl:otherwise>
      <![CDATA[<Web>]]>
      <xsl:for-each select="Web_Preview"><![CDATA[<File caption="caption" src="http://10.10.10.72/ContentDBSite/Temp]]><xsl:value-of select="."/><![CDATA["/>]]></xsl:for-each>
      <![CDATA[</Web>]]>
      </xsl:otherwise>
      </xsl:choose>
      <![CDATA[</Preview>]]>
      </xsl:when>
      </xsl:choose>
      <![CDATA[<Capability name="deliverytype" value="OTA"/>
      </ContentDescriptor>
      <WebDescriptor>
      <Category>Home:]]><xsl:value-of select="Provider_Name" />:<xsl:value-of select="Type_Class_Name" />:<xsl:value-of select="Type_SubClass_Name" />:<xsl:value-of select="Type_Name" /><![CDATA[</Category>
      <WebGroup>
      <DisplayName>]]><xsl:value-of select="$contentName"/><![CDATA[</DisplayName>
      <ShortDescription>]]><xsl:value-of select="$contentName"/><![CDATA[</ShortDescription>
      <LongDescription>]]><xsl:value-of select="$contentName"/><![CDATA[</LongDescription>
      </WebGroup>
      </WebDescriptor>
      <PriceDescriptor>
      <Free/>
      </PriceDescriptor>
      </ContentSubmission>]]>

      </xsl:result-document>
      </xsl:for-each>
      </xsl:template>

      </xsl:stylesheet>

    2. The following is a sample echo XSLT file:

      This XSLT are used to just generate XML file that is identical to the DOM created in the memory.

      <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <xsl:output method="xml" indent="yes"/>

      <xsl:template match="node()">
      <xsl:copy>
      <xsl:apply-templates/>
      </xsl:copy>
      </xsl:template>

      </xsl:stylesheet>

References

  1. http://java.sun.com/developer/EJTechTips/2004/tt0527.html
  2. http://www.topxml.com/xsl/articles/java_xslt/default.asp
  3. http://www.developer.com/xml/article.php/10929_2108031_2

efukut

awesome post that will I have been examine I favor that however it could be a lot more fascinating in case you compose document concerning getaway people just like at this website Pulau Tidung Pulau Seribu

I like this idea. I followed

I like this idea. I followed through, and it gave me a good result in the end. - Dony McGuire

Powered by Drupal - Design by artinet