TRANSFORM_dpr-to-dpr2-v1.0.xsl 3.32 KB
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dpr="http://www.witsml.org/schemas/131/addendum/combo"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://www.epim.no/schemas/mprml/1">

  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>

  <xsl:variable name="fieldname" select="/dpr:WITSMLComposite/dpr:documentInfo/dpr:DocumentAlias[@namingSystem='ERHFIELDNAME']" />
  <xsl:variable name="fieldid" select="/dpr:WITSMLComposite/dpr:documentInfo/dpr:DocumentAlias[@namingSystem='ERHFIELDID']" />

<!-- WITSMLComposite -> objects  --> 

  <xsl:template match="dpr:WITSMLComposite">

  <objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  			xmlns="http://www.epim.no/schemas/mprml/1" version="1.0(MPRML)">

       <xsl:apply-templates select="*|node()"/>
       
   </objects>
      
  </xsl:template>
  
<!-- documentInfo -> documentInfo and add context element  -->  

    <xsl:template match="dpr:documentInfo">
      
      	<xsl:element  name="documentInfo">
      		<xsl:apply-templates select="@*|node()"/>
       </xsl:element>
       
      <xsl:element  name="context">
      	<xsl:attribute name="xsi:type">obj_report</xsl:attribute>
      	<title>Vega DPRM</title>
      	 <date>2012-10-14</date>
      	  <reportStatus>final</reportStatus>
      	  	<xsl:element  name="installation"> 
      	  	<xsl:attribute name="kind">field</xsl:attribute>
      	  	<xsl:attribute name="namingSystem">NPD</xsl:attribute>
      	  	<xsl:attribute name="uidRef">
      	  	<xsl:value-of select="$fieldid" />
      	  	</xsl:attribute>
      	  <xsl:value-of select="$fieldname" />
      	  	</xsl:element> 
      	 
      </xsl:element> 
      
  </xsl:template>
  
  <!-- IGNORE productionOperationSet for now -->  
  
    <xsl:template match="dpr:productionOperationSet">
      
  </xsl:template>
  
<!-- productVolumeSet -> only children  -->  

  <xsl:template match="dpr:productVolumeSet">
      	<xsl:apply-templates select="@*|node()"/>
  </xsl:template>
  
  <!-- productVolumeSet @uid -> remove uid  --> 
  
  <xsl:template match="dpr:productVolumeSet/@uid">
      <xsl:apply-templates select="@*|node()"/>
  </xsl:template>
  
  <!-- productVolume -> object xsd:type=obj_productVolume   -->
  
  <xsl:template match="dpr:productVolume">
    <xsl:element  name="object">
    	<xsl:attribute name="xsi:type">obj_productVolume</xsl:attribute>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="dpr:installation">
    <xsl:element  name="installation">
    	<xsl:attribute name="kind">field</xsl:attribute>
    	<xsl:attribute name="namingSystem">NPD</xsl:attribute>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  
<!-- For any elements not covered above, copy them over but with the new namespace  -->
  <xsl:template match="dpr:*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>

  <!-- Convert anything else as-is -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>


</xsl:stylesheet>