Auto-transform an XML document into a different XML document

Oxygen general issues.
amagine
Posts: 1
Joined: Wed Oct 03, 2007 3:03 am

Auto-transform an XML document into a different XML document

Post by amagine »

I am outputting GIS data features into an XML/GML feature document.

example GIS Output:

Code: Select all

	
<gml:featureMember>
<gml2:CPSAesf2007>
<gml2:OBJECTID>1</gml2:OBJECTID>
<gml2:Opening/>
<gml2:Block_Code>0</gml2:Block_Code>
<gml2:Cutting_Permit>SA</gml2:Cutting_Permit>
<gml2:Opening_ID/>
<gml2:Shape_Length>717.814784004704</gml2:Shape_Length>
<gml2:Shape_Area>19865.6409278132</gml2:Shape_Area>
<gml2:cutBlockID>Blk 1</fta:cutBlockID>
<gml2:applicationPurpose>N</fta:applicationPurpose>
<gml2:plannedGrossArea>1.987</fta:plannedGrossArea>
<gml2:plannedNetArea>1.68</fta:plannedNetArea>
<gml2:plannedHarvestDate>2007-11-29</fta:plannedHarvestDate>
<gml:polygonProperty>
<gml:Polygon srsName="EPSG:42102">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>co-ordinate string</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonProperty>
</gml2:CPSAesf2007>
</gml:featureMember>
And I would like to transform the feature attributes and tags into something like this:

Code: Select all

   
<fta:cutblockMember>
<fta:CutBlockWithCP>
<fta:cutBlockID>Blk 1</fta:cutBlockID>
<fta:applicationPurpose>N</fta:applicationPurpose>
<fta:plannedGrossArea>1.987</fta:plannedGrossArea>
<fta:plannedNetArea>1.68</fta:plannedNetArea>
<fta:plannedHarvestDate>2007-11-29</fta:plannedHarvestDate>
<fta:extentOf>
<gml:Polygon srsName="EPSG:42102">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>co-ordinate string</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</fta:extentOf>
</fta:CutBlockWithCP>
</fta:cutblockMember>
I have been using the Find/Replace to change tags throughout the GIS documnent, however I do not know how to delete features which are not required information. And so Deletion of features has been done manually.

Is there a way to automate this task?

Thank you!

Mars
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

You can try to automate the task with an XSLT stylesheet that removes the elements that are included only in the input XML file and changes the namespace or the namespace prefix of the elements that are preserved in the output XML file as in your example.


Regards,
Sorin
Post Reply