David Price

Added initial DPR1 XSLT and sanitised test case.

1 +# baseURI: http://www.reportinghub.no/test/dpr/testcase/dpr-to-dpr2-runxslt
2 +# imports: http://topbraid.org/sparqlmotionfunctions
3 +# imports: http://topbraid.org/sparqlmotionlib-tbc
4 +
5 +@prefix : <http://www.reportinghub.no/test/dpr/testcase/dpr-to-dpr2-runxslt#> .
6 +@prefix owl: <http://www.w3.org/2002/07/owl#> .
7 +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
8 +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
9 +@prefix sm: <http://topbraid.org/sparqlmotion#> .
10 +@prefix sml: <http://topbraid.org/sparqlmotionlib#> .
11 +@prefix sp: <http://spinrdf.org/sp#> .
12 +@prefix spin: <http://spinrdf.org/spin#> .
13 +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
14 +
15 +<http://www.reportinghub.no/test/dpr/testcase/dpr-to-dpr2-runxslt>
16 + rdf:type owl:Ontology ;
17 + owl:imports <http://topbraid.org/sparqlmotionfunctions> , <http://topbraid.org/sparqlmotionlib-tbc> ;
18 + owl:versionInfo "Created with TopBraid Composer"^^xsd:string .
19 +
20 +:ConvertXMLByXSLT_1
21 + rdf:type sml:ConvertXMLByXSLT ;
22 + rdfs:label "Convert XMLBy XSLT 1"^^xsd:string ;
23 + sm:next :SaveTransformResult ;
24 + sm:nodeX 352 ;
25 + sm:nodeY 82 ;
26 + sm:outputVariable "xmlContent"^^xsd:string ;
27 + sml:template
28 + [ sp:varName "stylesheet"^^xsd:string
29 + ] ;
30 + sml:xml [ sp:varName "input"^^xsd:string
31 + ] .
32 +
33 +:ReadStylesheet
34 + rdf:type sml:ImportTextFile ;
35 + rdfs:label "Read stylesheet"^^xsd:string ;
36 + sm:next :ConvertXMLByXSLT_1 ;
37 + sm:nodeX 72 ;
38 + sm:nodeY 19 ;
39 + sm:outputVariable "stylesheet"^^xsd:string ;
40 + sml:sourceFilePath "/www.reportinghub.no/xslt/TRANSFORM_dpr-to-mpr-v1.0.xsl"^^xsd:string .
41 +
42 +:ReadXMLInput
43 + rdf:type sml:ImportTextFile ;
44 + rdfs:label "Read XMLInput"^^xsd:string ;
45 + sm:next :ConvertXMLByXSLT_1 ;
46 + sm:nodeX 623 ;
47 + sm:nodeY 9 ;
48 + sm:outputVariable "input"^^xsd:string ;
49 + 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 .
50 +
51 +:SaveTransformResult
52 + rdf:type sml:ExportToTextFile ;
53 + rdfs:label "Save transform result"^^xsd:string ;
54 + sm:nodeX 354 ;
55 + sm:nodeY 316 ;
56 + sml:replace "true"^^xsd:boolean ;
57 + sml:targetFilePath "RESULT-generated-dpr2.xml"^^xsd:string ;
58 + sml:text "{?xmlContent}"^^xsd:string .
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<WITSMLComposite xmlns="http://www.witsml.org/schemas/131/addendum/combo" version="1.3.1.0">
3 +<documentInfo>
4 +<DocumentName namingSystem="EC">Daily Production Vega Unit</DocumentName>
5 +<DocumentAlias namingSystem="EC">Daily Production and Operation Report</DocumentAlias>
6 +<DocumentDate>2012-10-14T00:00:00</DocumentDate>
7 +<documentClass namingSystem="EC">DPOR</documentClass>
8 +<documentClass namingSystem="EC">DPR</documentClass>
9 +<documentClass namingSystem="ERH">dpr2</documentClass>
10 +<Owner>VEGA</Owner>
11 +</documentInfo>
12 +<productVolumeSet>
13 +<productVolume uid="83CB36697A4C0A20E040618F80123BA7">
14 +<name>VEGA</name>
15 +<installation>VEGA</installation>
16 +<contextFacility kind="field" namingSystem="NPD" uidRef="4467595">VEGA</contextFacility>
17 +<kind>DDR</kind>
18 +<periodKind>day</periodKind>
19 +<dateStart>2012-10-14</dateStart>
20 +<dateEnd>2012-10-15</dateEnd>
21 +<operator>
22 +<name>Statoil ASA</name>
23 +<role>operator</role>
24 +</operator>
25 +<title namingSystem="EC">Daily Production Vega Unit</title>
26 +<facility uid="83CB36697A4C0A20E040618F80123BA7">
27 +<name kind="platform" namingSystem="NPD" uidRef="83CB36697A4C0A20E040618F80123BA7">VEGA NORD</name>
28 +<facilityParent1 kind="field" namingSystem="NPD" uidRef="4467595">VEGA</facilityParent1>
29 +<contextFacility kind="field" namingSystem="NPD" uidRef="4467595">VEGA</contextFacility>
30 +<flow uid="90D8148938DD01F5E040618F801225D4">
31 +<name>Liquid Partially Processed Vega Unit</name>
32 +<kind>production</kind>
33 +<direction>outlet</direction>
34 +<qualifier>measured</qualifier>
35 +<product>
36 +<kind>oil</kind>
37 +<name>Liquid Partially Processed Vega Unit</name>
38 +<period>
39 +<kind>day</kind>
40 +<dTimStart>2012-10-14T00:00:00</dTimStart>
41 +<dTimEnd>2012-10-15T00:00:00</dTimEnd>
42 +<volume uom="bbl">123.45</volume>
43 +<volumeStd uom="m3">678.436</volumeStd>
44 +</period>
45 +</product>
46 +<product>
47 +<kind>oil - net</kind>
48 +<name>Liquid Partially Processed Vega Unit</name>
49 +<period>
50 +<kind>day</kind>
51 +<dTimStart>2012-10-14T00:00:00</dTimStart>
52 +<dTimEnd>2012-10-15T00:00:00</dTimEnd>
53 +<volume uom="bbl">444.90145</volume>
54 +<volumeStd uom="m3">777.28209</volumeStd>
55 +<mass uom="tonUK">88.81853453</mass>
56 +</period>
57 +</product>
58 +</flow>
59 +</facility>
60 +</productVolume>
61 +</productVolumeSet>
62 +</WITSMLComposite>
...\ No newline at end of file ...\ No newline at end of file
1 +<xsl:stylesheet version="1.0"
2 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 + xmlns:dpr="http://www.witsml.org/schemas/131/addendum/combo"
4 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 + xmlns="http://www.epim.no/schemas/mprml/1">
6 +
7 + <xsl:strip-space elements="*"/>
8 + <xsl:output indent="yes"/>
9 +
10 +<!-- WITSMLComposite -> objects -->
11 +
12 + <xsl:template match="dpr:WITSMLComposite">
13 +
14 + <objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15 + xmlns="http://www.epim.no/schemas/mprml/1" version="1.0(MPRML)">
16 +
17 + <xsl:apply-templates select="*|node()"/>
18 +
19 + </objects>
20 +
21 + </xsl:template>
22 +
23 +<!-- documentInfo -> documentInfo and add context element -->
24 +
25 + <xsl:template match="dpr:documentInfo">
26 +
27 + <xsl:element name="documentInfo">
28 + <xsl:apply-templates select="@*|node()"/>
29 + </xsl:element>
30 +
31 + <xsl:element name="context">
32 + <xsl:attribute name="xsi:type">obj_report</xsl:attribute>
33 + <title>Vega DPRM</title>
34 + <date>2012-10-14</date>
35 + <reportStatus>final</reportStatus>
36 + <installation kind="field" namingSystem="NPD" uidRef="4467595">VEGA</installation>
37 + </xsl:element>
38 +
39 + </xsl:template>
40 +
41 +<!-- productVolumeSet -> only children -->
42 +
43 + <xsl:template match="dpr:productVolumeSet">
44 + <xsl:apply-templates select="@*|node()"/>
45 + </xsl:template>
46 +
47 + <!-- productVolumeSet @uid -> remove uid -->
48 +
49 + <xsl:template match="dpr:productVolumeSet/@uid">
50 + <xsl:apply-templates select="@*|node()"/>
51 + </xsl:template>
52 +
53 + <!-- productVolume -> object xsd:type=obj_productVolume -->
54 +
55 + <xsl:template match="dpr:productVolume">
56 + <xsl:element name="object">
57 + <xsl:attribute name="xsi:type">obj_productVolume</xsl:attribute>
58 + <xsl:apply-templates select="@*|node()"/>
59 + </xsl:element>
60 + </xsl:template>
61 +
62 + <xsl:template match="dpr:installation">
63 + <xsl:element name="installation">
64 + <xsl:attribute name="kind">field</xsl:attribute>
65 + <xsl:attribute name="namingSystem">NPD</xsl:attribute>
66 + <xsl:apply-templates select="@*|node()"/>
67 + </xsl:element>
68 + </xsl:template>
69 +
70 +
71 +<!-- For any elements not covered above, copy them over but with the new namespace -->
72 + <xsl:template match="dpr:*">
73 + <xsl:element name="{local-name()}">
74 + <xsl:apply-templates select="@*|node()"/>
75 + </xsl:element>
76 + </xsl:template>
77 +
78 + <!-- Convert anything else as-is -->
79 + <xsl:template match="@*|node()">
80 + <xsl:copy>
81 + <xsl:apply-templates select="@*|node()"/>
82 + </xsl:copy>
83 + </xsl:template>
84 +
85 +
86 +</xsl:stylesheet>