XML DTD XSLT
Conversion Code Example

Converting Mercator 6.5 Type Tree .DTD Source Files to Mercator 5.0.

Compare and identify the filesí Type Tree .DTD differences which will be needed to be changed in order to convert the 6.5 to 5.0 *.mts. All of these differences will have to be "handled" in the XML Text Nodes appropriately.

The major differences that have been encountered, documented and coded for are differences in the XML Text Nodes containing separate Elements vs. Attributes and the associated Contents of those elements and attributes.

************************************************************************

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"/>

<!-- delimited list of attributes that need to be converted to elements -->

<xsl:variable name="convert-atts">|SimpleTypeName|CategoryOrItemParent|partition|OrderSubtypes|Length|Description|Min|Max|</xsl:variable>

<xsl:template match="*">

<!-- copy of the element itself -->

<xsl:copy>

<!-- handle all attributes that don't need converting -->

<xsl:copy-of

select="@*[not(contains($convert-atts,concat('|',name(),'|')))]"/>

<!-- handle all child nodes plus attributes that are to be converted to

elements -->

<xsl:apply-templates select="node() |

@*[contains($convert-atts,concat('|',name(),'|'))]"/>

</xsl:copy>

</xsl:template>

<!-- template for copying over text, comment and pi nodes -->

<xsl:template match="text() | comment() | processing-instruction()">

<xsl:copy/>

</xsl:template>

<!-- template for converting attributes to elements -->

<xsl:template match="@*">

<xsl:element name="{name(.)}">

<xsl:value-of select="."/>

</xsl:element>

</xsl:template>

</xsl:stylesheet>

************************************************************************

Mercator 5.0 .mts

<?xml version="1.0" encoding='UTF-8'?>

<!DOCTYPE TTMAKER SYSTEM "ttmaker.dtd" >

<?ttmaker.exe ANALYZE?>

<TTMAKER>

<TypeTree>

<NEWTREE><FileName>C:\TEST\Mercator_V50\TypeTrees\TEST.mtt</FileName><Root><SimpleTypeName>CopyBook</SimpleTypeName><Description>COBOL copy book imported on 01/21/04 12:19:16</Description><gprop_implicit structure="sequence"></gprop_implicit><iprop_char_text><size><Min>0</Min><Max>S</Max></size></iprop_char_text></Root></NEWTREE>

<SETROOT><SimpleTypeName>CopyBook</SimpleTypeName></SETROOT>

<CATEGORYCLASS><SimpleTypeName>Field</SimpleTypeName><Description>Fields are components of Groups and Records</Description><gprop_implicit structure="sequence"></gprop_implicit><iprop_char_text><size><Min>0</Min><Max>S</Max></size></iprop_char_text></CATEGORYCLASS>

 

Mercator 6.5 .mts

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE TTMAKER SYSTEM "ttmaker60.dtd">

<TTMAKER Version="6.0">

<NEWTREE Filename="C:\TEST\Mercator_V65\TypeTrees\TEST.mtt"> <ROOT SimpleTypeName="CopyBook" Description="COBOL copy book imported on 02/09/04 12:14:08" SetUpProperties="DEFAULT" SetUpComponents="DELETE"><Sequence partition="NO"><Implicit/></Sequence>

<CharTextWestern><Size Min="0" Max="S"/>

<Western CharSet="NATIVE"/>

<ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>

</CharTextWestern>

</ROOT>

<CATEGORY SimpleTypeName="Field" CategoryParent="CopyBook" Description="Fields are components of Groups and Records" OrderSubtypes="ASCENDING"><Sequence partition="NO"><Implicit/></Sequence>

<CharTextWestern><Size Min="0" Max="S"/>

<Western CharSet="NATIVE"/>

<ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>

</CharTextWestern>

</CATEGORY>

<SETCATEGORY><CompleteTypeName>Field CopyBook</CompleteTypeName>

</SETCATEGORY>

***********************************************************************

Mercator 5.0 .mts

<ITEMCLASS>

<SimpleTypeName>TEST_ALTPAY_ADDR_LINE1</SimpleTypeName>

<Description>10 TEST-ALTPAY-ADDR-LINE1 PIC X(30).</Description>

<iprop_char_text>

<size>

<Min>0</Min>

<Max>30</Max>

</size>

<PadText justify="LEFT" ApplyPad="ANYCONTEXT">

<PadValue> </PadValue>

<PaddedTo>

<FixedSize>30</FixedSize>

</PaddedTo>

</PadText>

</iprop_char_text>

</ITEMCLASS>

 

Mercator 6.5 .mts

<ITEM SimpleTypeName="TEST_ALTPAY_ADDR_LINE1"

CategoryOrItemParent="Field CopyBook"

Description="10 TEST-ALTPAY-ADDR-LINE1 PIC X(30)."

partition="NO"

OrderSubtypes="ASCENDING">

<CharTextWestern>

<Size Min="0" Max="30"/>

<PadText Justify="LEFT" ApplyPad="ANYCONTEXT">

<PadValue>&lt;SP&gt;</PadValue>

PaddedToFixedSize Length="30"/>

</PadText>

<Western CharSet="NATIVE"/>

<ValueRestrictions

IgnoreCase="NO"

Rule="INCLUDE">

</ValueRestrictions>

</CharTextWestern>

</ITEM> <SETCATEGORY><CompleteTypeName>Field CopyBook</CompleteTypeName>

</SETCATEGORY>

************************************************************************

Mercator 5.0 .mts

<ITEMCLASS>

<SimpleTypeName>TEST_ALTPAY_ZIP4</SimpleTypeName>

<Description>15 TEST-ALTPAY-ZIP4 PIC 9(04).</Description>

<iprop_char_integer_number WesternCharSet="NATIVE">

<IntegerFormatString>{######}</IntegerFormatString>

<TotalDigits>

<Min>0</Min>

<Max>4</Max>

</TotalDigits>

<PadNumber justify="RIGHT" ApplyPad="ANYCONTEXT" fill="BEFORE">

<PadValue>0</PadValue>

<PaddedTo><FixedSize>4</FixedSize></PaddedTo>

</PadNumber>

</iprop_char_integer_number>

</ITEMCLASS>

 

Mercator 6.5 .mts

<ITEM SimpleTypeName="TEST_ALTPAY_ZIP4"

CategoryOrItemParent="Field CopyBook"

Description="15 TEST-ALTPAY-ZIP4 PIC 9(04)."

partition="NO"

OrderSubtypes="ASCENDING">

<CharNumber>

<CharInt>

<TotalDigits Min="0" Max="4"/>

<PadNumber

Justify="RIGHT"

ApplyPad="ANYCONTEXT"

Fill="BEFORE">

<PadValue>0</PadValue>

<PaddedToFixedSize Length="4"/>

</PadNumber>

<IntegerFormatString>{######}</IntegerFormatString>

</CharInt>

<Western CharSet="NATIVE"/>

<ValueRestrictions

IgnoreCase="NO"

Rule="INCLUDE">

</ValueRestrictions>

</CharNumber>

</ITEM>

<SETCATEGORY><CompleteTypeName>Field CopyBook</CompleteTypeName>

</SETCATEGORY>

************************************************************************

Mercator 5.0 .mts

<ITEMCLASS><SimpleTypeName>TEST_CMPD_PRD_ID_QUAL</SimpleTypeName>

<Description>15 TEST-CMPD-PRD-ID-QUAL PIC X(02).</Description>

<iprop_char_text>

<size>

<Min>0</Min>

<Max>2</Max>

</size>

<PadText justify="LEFT"

ApplyPad="ANYCONTEXT">

<PadValue> </PadValue>

<PaddedTo>

<FixedSize>2</FixedSize>

</PaddedTo>

</PadText>

</iprop_char_text>

</ITEMCLASS>

<SETITEM>

<CompleteTypeName>TEST_CMPD_PRD_ID_QUAL Field CopyBook</CompleteTypeName>

</SETITEM>

<AddRestriction>

<Restriction>03</Restriction>

<Description>TEST_CMPD_PRD_ID_NDC</Description>

</AddRestriction>

 

Mercator 6.5 .mts

<ITEM

SimpleTypeName="TEST_CMPD_PRD_ID_QUAL"

CategoryOrItemParent="Field CopyBook"

Description="15 TEST-CMPD-PRD-ID-QUAL PIC X(02)."

partition="NO"

OrderSubtypes="ASCENDING">

<CharTextWestern>

<Size Min="0"

Max="2"/>

<PadText Justify="LEFT"

ApplyPad="ANYCONTEXT">

<PadValue>&lt;SP&gt;</PadValue>

<PaddedToFixedSize Length="2"/>

</PadText>

<Western CharSet="NATIVE"/>

<ValueRestrictions

IgnoreCase="NO"

Rule="INCLUDE">

<Value Description="TEST_CMPD_PRD_ID_NDC">03</Value>

<Value Description="TEST_CMPD_PRD_ID_VALID">03</Value>

</ValueRestrictions>

</CharTextWestern>

</ITEM>

<SETCATEGORY><CompleteTypeName>Group CopyBook</CompleteTypeName>

</SETCATEGORY>

************************************************************************

Mercator 5.0 .mts

<GROUPCLASS>

<SimpleTypeName>TEST_ASSC_RX_SERVICE_DT_X</SimpleTypeName>

<Description>15 TEST-ASSC-RX-SERVICE-DT-X.</Description>

<gprop_implicit structure="sequence"></gprop_implicit>

</GROUPCLASS>

<SETGROUP>

<CompleteTypeName>TEST_ASSC_RX_SERVICE_DT_X Group CopyBook</CompleteTypeName>

</SETGROUP>

<AddComponent>

<RelativeTypeName>TEST_ASSC_RX_SERVICE_DT Field</RelativeTypeName>

<Range>

<Min>1</Min>

<Max>1</Max>

</Range>

</AddComponent>

 

Mercator 6.5 .mts

<GROUP SimpleTypeName="TEST_ASSC_RX_SERVICE_DT_X"

CategoryOrGroupParent="Group CopyBook"

Description="15 TEST-ASSC-RX-SERVICE-DT-X."

OrderSubtypes="ASCENDING">

<Sequence partition="NO">

<Implicit/>

<SequenceComponent>

<RelativeTypeName>TEST_ASSC_RX_SERVICE_DT Field</RelativeTypeName>

<Range

Min="1"

Max="1"/>

</SequenceComponent>

</Sequence>

</GROUP>

Go Back to:
http://Howes-IT-Going.com

This Webpage and Contents Created by Steven C. Howes © Howes-IT-Going 2004-2010 All rights reserved.