David Price

Added initial DPR1 XSLT and sanitised test case.

# baseURI: http://www.reportinghub.no/test/dpr/testcase/dpr-to-dpr2-runxslt
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib-tbc
@prefix : <http://www.reportinghub.no/test/dpr/testcase/dpr-to-dpr2-runxslt#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sm: <http://topbraid.org/sparqlmotion#> .
@prefix sml: <http://topbraid.org/sparqlmotionlib#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://www.reportinghub.no/test/dpr/testcase/dpr-to-dpr2-runxslt>
rdf:type owl:Ontology ;
owl:imports <http://topbraid.org/sparqlmotionfunctions> , <http://topbraid.org/sparqlmotionlib-tbc> ;
owl:versionInfo "Created with TopBraid Composer"^^xsd:string .
:ConvertXMLByXSLT_1
rdf:type sml:ConvertXMLByXSLT ;
rdfs:label "Convert XMLBy XSLT 1"^^xsd:string ;
sm:next :SaveTransformResult ;
sm:nodeX 352 ;
sm:nodeY 82 ;
sm:outputVariable "xmlContent"^^xsd:string ;
sml:template
[ sp:varName "stylesheet"^^xsd:string
] ;
sml:xml [ sp:varName "input"^^xsd:string
] .
:ReadStylesheet
rdf:type sml:ImportTextFile ;
rdfs:label "Read stylesheet"^^xsd:string ;
sm:next :ConvertXMLByXSLT_1 ;
sm:nodeX 72 ;
sm:nodeY 19 ;
sm:outputVariable "stylesheet"^^xsd:string ;
sml:sourceFilePath "/www.reportinghub.no/xslt/TRANSFORM_dpr-to-mpr-v1.0.xsl"^^xsd:string .
:ReadXMLInput
rdf:type sml:ImportTextFile ;
rdfs:label "Read XMLInput"^^xsd:string ;
sm:next :ConvertXMLByXSLT_1 ;
sm:nodeX 623 ;
sm:nodeY 9 ;
sm:outputVariable "input"^^xsd:string ;
sml:sourceFilePath "/www.reportinghub.no/test/dpr/testcase/Field Vega - BAA Vega/tqedits/Daily Production Vega Unit 2012-10-14-ONE-FLOW.xml"^^xsd:string .
:SaveTransformResult
rdf:type sml:ExportToTextFile ;
rdfs:label "Save transform result"^^xsd:string ;
sm:nodeX 354 ;
sm:nodeY 316 ;
sml:replace "true"^^xsd:boolean ;
sml:targetFilePath "RESULT-generated-dpr2.xml"^^xsd:string ;
sml:text "{?xmlContent}"^^xsd:string .
<?xml version="1.0" encoding="UTF-8"?>
<WITSMLComposite xmlns="http://www.witsml.org/schemas/131/addendum/combo" version="1.3.1.0">
<documentInfo>
<DocumentName namingSystem="EC">Daily Production Vega Unit</DocumentName>
<DocumentAlias namingSystem="EC">Daily Production and Operation Report</DocumentAlias>
<DocumentDate>2012-10-14T00:00:00</DocumentDate>
<documentClass namingSystem="EC">DPOR</documentClass>
<documentClass namingSystem="EC">DPR</documentClass>
<documentClass namingSystem="ERH">dpr2</documentClass>
<Owner>VEGA</Owner>
</documentInfo>
<productVolumeSet>
<productVolume uid="83CB36697A4C0A20E040618F80123BA7">
<name>VEGA</name>
<installation>VEGA</installation>
<contextFacility kind="field" namingSystem="NPD" uidRef="4467595">VEGA</contextFacility>
<kind>DDR</kind>
<periodKind>day</periodKind>
<dateStart>2012-10-14</dateStart>
<dateEnd>2012-10-15</dateEnd>
<operator>
<name>Statoil ASA</name>
<role>operator</role>
</operator>
<title namingSystem="EC">Daily Production Vega Unit</title>
<facility uid="83CB36697A4C0A20E040618F80123BA7">
<name kind="platform" namingSystem="NPD" uidRef="83CB36697A4C0A20E040618F80123BA7">VEGA NORD</name>
<facilityParent1 kind="field" namingSystem="NPD" uidRef="4467595">VEGA</facilityParent1>
<contextFacility kind="field" namingSystem="NPD" uidRef="4467595">VEGA</contextFacility>
<flow uid="90D8148938DD01F5E040618F801225D4">
<name>Liquid Partially Processed Vega Unit</name>
<kind>production</kind>
<direction>outlet</direction>
<qualifier>measured</qualifier>
<product>
<kind>oil</kind>
<name>Liquid Partially Processed Vega Unit</name>
<period>
<kind>day</kind>
<dTimStart>2012-10-14T00:00:00</dTimStart>
<dTimEnd>2012-10-15T00:00:00</dTimEnd>
<volume uom="bbl">123.45</volume>
<volumeStd uom="m3">678.436</volumeStd>
</period>
</product>
<product>
<kind>oil - net</kind>
<name>Liquid Partially Processed Vega Unit</name>
<period>
<kind>day</kind>
<dTimStart>2012-10-14T00:00:00</dTimStart>
<dTimEnd>2012-10-15T00:00:00</dTimEnd>
<volume uom="bbl">444.90145</volume>
<volumeStd uom="m3">777.28209</volumeStd>
<mass uom="tonUK">88.81853453</mass>
</period>
</product>
</flow>
</facility>
</productVolume>
</productVolumeSet>
</WITSMLComposite>
\ No newline at end of file
<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"/>
<!-- 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>
<installation kind="field" namingSystem="NPD" uidRef="4467595">VEGA</installation>
</xsl:element>
</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>