ArcFM Desktop Developer Guide
XSL Style Sheet Sample

Resource Center Home

Below is a sample XSL style sheet. Use this sample as a guide when creating your own style sheet. The sample applies to MultiSpeak implementations.

Depending on your setup, there are two XSL and two DTD files to configure:

Windmil - Standard Electric Distribution Data Model Purpose
NetAdapterElecDistToMsp_Windmil.xsl This is the stylesheet that makes the transformation. This is the file that should be configured in the XSL Transformation Pipeline rule.
NetAdapterElecDistToMsp_DMSEquipment.xsl Equipment Stylesheet. This generates equipment IDs based on some key attributes in the feature database.
NetAdapterElecDistToMspFields.dtd This DTD defines field names.
NetAdapterElecDistToMsp.dtd This DTD defines class names, relationships, subtype codes, and int.

Windmil - MultiSpeak Electric Distribution Data Purpose
NetAdapterMspEAExport.xsl This is the stylesheet that makes the transformation. This is the file that should be configured in the XSL Transformation Pipeline rule.
NetAdapterMspEAExport_Equipment.xsl Equipment Stylesheet. This generates equipment IDs based on some key attributes in the feature database.
NetAdapterMspEAExportFields.dtd This DTD defines field names.
NetAdapterMspEAExport.dtd This DTD defines class names, relationships, subtype codes, and int.
XSL Sample
Copy Code
<?xml version="1.0" encoding="UTF-8" ?> 
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
- <!-- 
 Declare a template of attributes to use when creating a LAYER element 
  --> 
- <xsl:attribute-set name="AttrSetLayer">
  <xsl:attribute name="ProgID" /> 
  <xsl:attribute name="Name" /> 
  <xsl:attribute name="TableName" /> 
  </xsl:attribute-set>
- <!-- 
 Declare a template of attributes to use when creating a FEATURE element 
  -->  
- <xsl:attribute-set name="AttrSetFeature">
  <xsl:attribute name="ProgID" /> 
  <xsl:attribute name="ID" /> 
  <xsl:attribute name="Type" /> 
  </xsl:attribute-set>
- <!-- 
 Start processing by matching the whole XML document 
  -->  
- <xsl:template match="/">
- <!-- 
 Create the document element 
  -->  
- <xsl:element name="DISTOPSEXPORT">
- <!-- 
 Create the LAYER element, use the attribute set AttrSetLayer 
  -->  
- <xsl:element name="LAYER" use-attribute-sets="AttrSetLayer">
- <!-- 
 populate the attributes of the element 
  -->  
- <xsl:attribute name="ProgID">
  <xsl:value-of select="DISTOPSEXPORT/LAYER[@TableName='PriUGElectricLineSegment']/@ProgID" /> 
  </xsl:attribute>
- <xsl:attribute name="Name">
  <xsl:value-of select="DISTOPSEXPORT/LAYER[@TableName='PriUGElectricLineSegment']/@Name" /> 
  </xsl:attribute>
- <xsl:attribute name="TableName">
  <xsl:value-of select="DISTOPSEXPORT/LAYER[@TableName='PriUGElectricLineSegment']/@TableName" /> 
  </xsl:attribute>
- <!-- 
 Copy the DATABASE element using copy-of to get all related values in the current element 
  -->  
  <xsl:copy-of select="DISTOPSEXPORT/LAYER[@TableName='PriUGElectricLineSegment']/DATABASE" /> 
- <!-- 
 apply the template 'NORMALIZEFEATURES' to the LAYER element that contains information for PriUGElectricLineSegment 
  -->  
  <xsl:apply-templates select="/DISTOPSEXPORT/LAYER[@TableName='PriUGElectricLineSegment']/FEATURE" mode="NORMALIZEFEATURES" /> 
  </xsl:element>
  </xsl:element>
  </xsl:template>
- <!-- 
 The template to normalize PriUGElectricLineSegment.
 create a match of only FEATURE elements that match the PriUGElectricLineSegment
 define a 'mode' attribute to further specify what template to call from an apply-templates 
  -->  
- <xsl:template match="FEATURE[TABLE='PriUGElectricLineSegment']" mode="NORMALIZEFEATURES">
- <!-- 
 Create a FEATURE element using the defined attribute set for features 
  -->  
- <xsl:element name="FEATURE" use-attribute-sets="AttrSetFeature">
- <!-- 
 populate the attributes 
  -->  
- <xsl:attribute name="ProgID">
  <xsl:value-of select="FEATURE/@ProgID" /> 
  </xsl:attribute>
- <xsl:attribute name="ID">
  <xsl:value-of select="DISTOPSEXPORT/LAYER/FEATURE/@ID" /> 
  </xsl:attribute>
- <xsl:attribute name="Type">
  <xsl:value-of select="DISTOPSEXPORT/LAYER/FEATURE/@Type" /> 
  </xsl:attribute>
- <!-- 
 create exact copies of the TABLE, LENGTH and EDGE elements 
  -->  
  <xsl:copy-of select="TABLE" /> 
  <xsl:copy-of select="LENGTH" /> 
  <xsl:copy-of select="EDGE" /> 
- <!-- 
 create a new RELATIONSHIP element 
  -->  
- <xsl:element name="RELATIONSHIP">
- <!-- 
 declare some variables to capture the A, B, and C phases for Condustor Size and Conductor Material 
  -->  
  <xsl:variable name="varCondSizeA" select="FIELDS/FIELD[FIELDNAME='CONDUCTORSIZE_A']/FIELDVALUE" /> 
  <xsl:variable name="varCondSizeB" select="FIELDS/FIELD[FIELDNAME='CONDUCTORSIZE_B']/FIELDVALUE" /> 
  <xsl:variable name="varCondSizeC" select="FIELDS/FIELD[FIELDNAME='CONDUCTORSIZE_C']/FIELDVALUE" /> 
  <xsl:variable name="varCondMatA" select="FIELDS/FIELD[FIELDNAME='CONDUCTORMATERIAL_A']/FIELDVALUE" /> 
  <xsl:variable name="varCondMatB" select="FIELDS/FIELD[FIELDNAME='CONDUCTORMATERIAL_B']/FIELDVALUE" /> 
  <xsl:variable name="varCondMatC" select="FIELDS/FIELD[FIELDNAME='CONDUCTORMATERIAL_C']/FIELDVALUE" /> 
- <!-- 
 if the A Phase value for size or material exists, create a new related conductorinfo record for it 
  -->  
- <xsl:if test="$varCondSizeA != '' or $varCondMatA != ''">
- <!-- 
 create a new FEATURE element under the RELATIONSHIP element 
  -->  
- <xsl:element name="FEATURE">
- <!-- 
 create a new TABLE element under the FEATURE element 
  -->  
- <xsl:element name="TABLE">
  <xsl:text>CONDUCTORINFO</xsl:text> 
  </xsl:element>
- <!-- 
 populate the Conductor Size value for the info record if it exists 
  -->  
- <xsl:element name="FIELDS">
- <xsl:if test="$varCondSizeA != ''">
- <xsl:element name="FIELD">
- <xsl:element name="FIELDNAME">
  <xsl:text>CONDUCTORSIZE</xsl:text> 
  </xsl:element>
- <xsl:element name="FIELDVALUE">
- <!-- 
 get the value of the variable assigned above 
  -->  
  <xsl:value-of select="$varCondSizeA" /> 
  </xsl:element>
  </xsl:element>
  </xsl:if>
- <!-- 
 populate the Conductor Material value for the info record if it exists 
  -->  
- <xsl:if test="$varCondMatA != ''">
- <xsl:element name="FIELD">
- <xsl:element name="FIELDNAME">
  <xsl:text>CONDUCTORMATERIAL</xsl:text> 
  </xsl:element>
- <xsl:element name="FIELDVALUE">
- <!-- 
 get the value of the variable assigned above 
  -->  
  <xsl:value-of select="$varCondMatA" /> 
  </xsl:element>
  </xsl:element>
  </xsl:if>
  </xsl:element>
  </xsl:element>
  </xsl:if>
- <!-- 
 if the B Phase value for size or material exists, create a new related conductorinfo record for it 
  -->  
- <xsl:if test="$varCondSizeB != '' or $varCondMatB != ''">
- <!-- 
 create a new FEATURE element under the RELATIONSHIP element 
  -->  
- <xsl:element name="FEATURE">
- <!-- 
 create a new TABLE element under the FEATURE element 
  -->  
- <xsl:element name="TABLE">
  <xsl:text>CONDUCTORINFO</xsl:text> 
  </xsl:element>
- <!-- 
 populate the Conductor Size value for the info record if it exists 
  -->  
- <xsl:element name="FIELDS">
- <xsl:if test="$varCondSizeB != ''">
- <xsl:element name="FIELD">
- <xsl:element name="FIELDNAME">
  <xsl:text>CONDUCTORSIZE</xsl:text> 
  </xsl:element>
- <xsl:element name="FIELDVALUE">
- <!-- 
 get the value of the variable assigned above 
  -->  
  <xsl:value-of select="$varCondSizeB" /> 
  </xsl:element>
  </xsl:element>
  </xsl:if>
- <!-- 
 populate the Conductor Material value for the info record if it exists 
  -->  
- <xsl:if test="$varCondMatB != ''">
- <xsl:element name="FIELD">
- <xsl:element name="FIELDNAME">
  <xsl:text>CONDUCTORMATERIAL</xsl:text> 
  </xsl:element>
- <xsl:element name="FIELDVALUE">
- <!-- 
 get the value of the variable assigned above 
  -->  
  <xsl:value-of select="$varCondMatB" /> 
  </xsl:element>
  </xsl:element>
  </xsl:if>
  </xsl:element>
  </xsl:element>
  </xsl:if>
- <!-- 
 if the C Phase value for size or material exists, create a new related conductorinfo record for it 
  -->  
- <xsl:if test="$varCondSizeC != '' or $varCondMatC != ''">
- <!-- 
 create a new FEATURE element under the RELATIONSHIP element 
  -->  
- <xsl:element name="FEATURE">
- <!-- 
 create a new TABLE element under the FEATURE element 
  -->  
- <xsl:element name="TABLE">
  <xsl:text>CONDUCTORINFO</xsl:text> 
  </xsl:element>
- <!-- 
 populate the Conductor Size value for the info record if it exists 
  -->  
- <xsl:element name="FIELDS">
- <xsl:if test="$varCondSizeC != ''">
- <xsl:element name="FIELD">
- <xsl:element name="FIELDNAME">
  <xsl:text>CONDUCTORSIZE</xsl:text> 
  </xsl:element>
- <xsl:element name="FIELDVALUE">
- <!-- 
 get the value of the variable assigned above 
  -->  
  <xsl:value-of select="$varCondSizeC" /> 
  </xsl:element>
  </xsl:element>
  </xsl:if>
- <!-- 
 populate the Conductor Material value for the info record if it exists 
  -->  
- <xsl:if test="$varCondMatC != ''">
- <xsl:element name="FIELD">
- <xsl:element name="FIELDNAME">
  <xsl:text>CONDUCTORMATERIAL</xsl:text> 
  </xsl:element>

- <xsl:element name="FIELDVALUE">
- <!-- 
 get the value of the variable assigned above 
  -->  
  <xsl:value-of select="$varCondMatC" /> 
  </xsl:element>
  </xsl:element>
  </xsl:if>
  </xsl:element>
  </xsl:element>
  </xsl:if>
  </xsl:element>
  </xsl:element>
  </xsl:template>
  </xsl:stylesheet>

 

 

 


Send Comment to ArcFMdocumentation@schneider-electric.com