[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

=?utf-8?Q?Re=3A_=5Bxml-dev=5D_Convert_one_XML_format_to_another_a?==?utf

  • From: Michael Kay <mike@saxonica.com>
  • To: Roger L Costello <costello@mitre.org>
  • Date: Sat, 29 Jun 2024 23:28:54 +0100

=?utf-8?Q?Re=3A_=5Bxml-dev=5D_Convert_one_XML_format_to_another_a?==?utf
"Verifying the conversion" means testing that your code is doing what it is supposed to do.

If you have a good specification then you can construct tests by testing that every statement in the specification is satisfied. But it's unusual to have a good specification, in which casse it's up to you to fill in the gaps. Ideally, the tests will be written by a different person, to ensure that the spec is being read and interpreted in the same way by two independent people.

Verifying that the output conforms to a particular schema is likely to be useful but is unlikely to be sufficient, since the schema knows nothing about the input.

I'm not sure that your "metadata" contributes anything useful to this exercise.

Michael Kay
Saxonica

On 29 Jun 2024, at 16:59, Roger L Costello <costello@mitre.org> wrote:

Hi Folks,

I am writing a program that converts an old XML format to a new XML format. In addition to doing the conversion, I also need to verify the conversion. I have two questions:
 
1.       What does it mean to “verify the conversion”? Does XSD validation constitute verifying the conversion? My sense is no. My sense is that each action taken during the conversion must be verified. Do you agree with that?
2.       As I do the conversion, I simultaneously output (to a separate file) metadata for each conversion action. What metadata should I generate to enable the conversion to be verified?
 
Allow me to explain …
 
My program converts this old format:
 
<Airport_Name>Boston Logan Airport</Airport_Name>
 
to this new format:
 
<name>Boston Logan Airport</name>
 
Old format:
 
<Airport_Elevation>19</Airport_Elevation>
 
New format:
 
<elevation>19</elevation>
 
Old:
 
<Airport_Reference_Point_Latitude>N42214660</Airport_Reference_Point_Latitude>
 
New:
 
<latitude>
    
<deg>42</deg>
    
<min>21</min>
    
<sec>46</sec>
    
<hSec>60</hSec>
    
<northSouth>North</northSouth>
</latitude>
 
Not only am I responsible for converting the old format to the new format, I am also required to verify the conversion. 
 
Truthfully, I am unclear what it means to “verify the conversion.” There is an XML Schema for the new format. I could (and certainly will) validate the file that is generated by my program. Is XSD-validation verifying the conversion? My sense is no. I think that “verify the conversion” means verify each action taken during the conversion. Do you agree with that?
 
“… verify each action taken during the conversion.” Here’s my plan of attack: My program will output -- to another, different file -- metadata that describes the actions that were taken during the conversion.
 
Once again, I am unclear. What metadata is needed to verify an action? The metadata will be machine processed, so I am thinking that the metadata had better contain predicates (expressions that evaluate to true or false) since they can be easily evaluated by a machine.
 
Here’s the metadata that I am currently generating when I convert Airport_Name to name:
 
<mapping>
    
<description>Map Airport_Name to name</description>
    
<legacy-elmt-name>Airport_Name</legacy-elmt-name>
    
<legacy-elmt-value>GENERAL EDWARD LAWRENCE LOGAN </legacy-elmt-value>
    
<new-elmt-name>name</new-elmt-name>
    
<new-elmt-value>GENERAL EDWARD LAWRENCE LOGAN</new-elmt-value>
    
<predicate>Airport_Name = name</predicate>
</mapping>
 

The value of <predicate> is a predicate expression (does the value of Airport_Name equal the value of name).

Here’s the metadata that I generate when I convert Airport_Elevation to elevation:

<mapping>
    
<description>Map Airport_Elevation to elevation</description>
    
<legacy-elmt-name>Airport_Elevation</legacy-elmt-name>
    
<legacy-elmt-value>19</legacy-elmt-value>
    
<new-elmt-name>elevation</new-elmt-name>
    
<new-elmt-value>19</new-elmt-value>
    
<predicate>Airport_Elevation = elevation</predicate>
</mapping>

 

Here’s the metadata that I generate when I convert Airport_Reference_Point_Latitude to latitude:

<mapping>
    
<description>Map Airport_Reference_Point_Latitude to latitude</description>
    
<legacy-elmt-name>Airport_Reference_Point_Latitude</legacy-elmt-name>
    
<legacy-elmt-value>N42214660</legacy-elmt-value>
    
<new-elmt-name>latitude</new-elmt-name>
    
<new-elmt-value>
        
<latitude>
            
<deg>42</deg>
            
<min>21</min>
            
<sec>46</sec>
            
<hSec>60</hSec>
            
<northSouth>North</northSouth>
        
</latitude>
    
</new-elmt-value>
    
<predicate>
       substring(Airport_Reference_Point_Latitude,2,2) = latitude/deg and
       substring(Airport_Reference_Point_Latitude,4,2) = latitude/min and
       substring(Airport_Reference_Point_Latitude,6,2) = latitude/sec and
       substring(Airport_Reference_Point_Latitude,8,2) = latitude/hSec and
       (
         (substring(Airport_Reference_Point_Latitude,1,1) = 'N' and latitude/NorthSouth = 'North') or
        (substring(Airport_Reference_Point_Latitude,1,1) = 'S' and latitude/NorthSouth = 'South') or
        (empty(latitude/NorthSouth))
      )

    </predicate>

</mapping>

 

Is that the metadata I should generate to enable the conversion to be verified?

/Roger




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.