Cook’n up some XML
Why is XML so difficult?XML is a languageThe language describes the data structures as well as the data contentXML folks revel in complex data structuresHierarchical data structuresGIS are usually based on relational data modelsFME & XMLYou tell FME how to interpret the XML data structures.
Reading XMLOptions for Reading XML with FMEGML 3.2 &  XSDMost GML can be interpreted if FME can use the XSDThis will work if the OGC spec. is followed and internal feature constructs are not overly complex.Xfmapscript for mapping XML structure to FME featuresXqueryW3C compliant XqueryMap XML tags to features or attributes using XQueryExploder & XQueryExtractor3
XML Formats - Reading4
Writing XMLOptions for Writing XML with FMEGML standard formatsFME supports a wide range of GML profiles (GML SF0, OS MasterMap, CityGML, etc.)GML 3.2 &  XSLTApply an XSLT (Extensible StylesheetLanguage Transformations) to the outputXqueryW3C compliant XqueryMap FME features to XML templates using XMLTemplater transformer5
XML Formats - Writing6
Writing XML - XMLTemplater7<feederObjectobjectID="{fme:get-attribute("objectID")}">  <feederName>{fme:get-attribute("feederName")}</feederName>  <feederNo>{fme:get-attribute("feederNo")}</feederNo>  <eaLoc>{fme:get-attribute("eaLoc")}</eaLoc></feederObject>
Example: XML Object hierarchyCreating an electricsubstation XML:CoordinatesandAttributesand containsFeeder(s) containAttributesXML DocumentSubstationFeeder AFeeder B
ExampleSample XML:Source of XML templatesAdd Xquery: replace attribute values with Xquery statementsSample XML   <substationobjectID="Vancouver Substation">      <mapLocation>        <coord>          <X>669170.169</X>          <Y>1000199.534</Y>        </coord>      </mapLocation>      <facilityID>5E67B377</facilityID>      <sectionID>RPG123</sectionID>      <phaseCode>ABC</phaseCode>     <feederList>        <feederObjectobjectID="8-64">          <feederName>10-24</feederName>          <feederNo>8763</feederNo>          <eaLoc>9D2D</eaLoc>        </feederObject>        <feederObjectobjectID="8-65">          <feederName>10-25</feederName>          <feederNo>8766</feederNo>          <eaLoc>9D3F</eaLoc>        </feederObject>      </feederList>      <name>Vancouver Central</name>  </substation><feederObjectobjectID="{fme:get-attribute("objectID")}">  <feederName>{fme:get-attribute("feederName")}</feederName>  <feederNo>{fme:get-attribute("feederNo")}</feederNo>  <eaLoc>{fme:get-attribute("eaLoc")}</eaLoc></feederObject>

Top FME Recipes: Cook’nup XML

  • 1.
  • 2.
    Why is XMLso difficult?XML is a languageThe language describes the data structures as well as the data contentXML folks revel in complex data structuresHierarchical data structuresGIS are usually based on relational data modelsFME & XMLYou tell FME how to interpret the XML data structures.
  • 3.
    Reading XMLOptions forReading XML with FMEGML 3.2 & XSDMost GML can be interpreted if FME can use the XSDThis will work if the OGC spec. is followed and internal feature constructs are not overly complex.Xfmapscript for mapping XML structure to FME featuresXqueryW3C compliant XqueryMap XML tags to features or attributes using XQueryExploder & XQueryExtractor3
  • 4.
  • 5.
    Writing XMLOptions forWriting XML with FMEGML standard formatsFME supports a wide range of GML profiles (GML SF0, OS MasterMap, CityGML, etc.)GML 3.2 & XSLTApply an XSLT (Extensible StylesheetLanguage Transformations) to the outputXqueryW3C compliant XqueryMap FME features to XML templates using XMLTemplater transformer5
  • 6.
  • 7.
    Writing XML -XMLTemplater7<feederObjectobjectID="{fme:get-attribute("objectID")}"> <feederName>{fme:get-attribute("feederName")}</feederName> <feederNo>{fme:get-attribute("feederNo")}</feederNo> <eaLoc>{fme:get-attribute("eaLoc")}</eaLoc></feederObject>
  • 8.
    Example: XML ObjecthierarchyCreating an electricsubstation XML:CoordinatesandAttributesand containsFeeder(s) containAttributesXML DocumentSubstationFeeder AFeeder B
  • 9.
    ExampleSample XML:Source ofXML templatesAdd Xquery: replace attribute values with Xquery statementsSample XML <substationobjectID="Vancouver Substation"> <mapLocation> <coord> <X>669170.169</X> <Y>1000199.534</Y> </coord> </mapLocation> <facilityID>5E67B377</facilityID> <sectionID>RPG123</sectionID> <phaseCode>ABC</phaseCode> <feederList> <feederObjectobjectID="8-64"> <feederName>10-24</feederName> <feederNo>8763</feederNo> <eaLoc>9D2D</eaLoc> </feederObject> <feederObjectobjectID="8-65"> <feederName>10-25</feederName> <feederNo>8766</feederNo> <eaLoc>9D3F</eaLoc> </feederObject> </feederList> <name>Vancouver Central</name> </substation><feederObjectobjectID="{fme:get-attribute("objectID")}"> <feederName>{fme:get-attribute("feederName")}</feederName> <feederNo>{fme:get-attribute("feederNo")}</feederNo> <eaLoc>{fme:get-attribute("eaLoc")}</eaLoc></feederObject>

Editor's Notes

  • #6 XML document CONTAINS a substation feature which CONTAINS several Feeder objects
  • #7  Copy the XML template from an exiting sample of the XML replace the attribute values with XQuery statements repeat for other XML tags (i.e. substation)