diff --git a/.gitignore b/.gitignore index a7f6a18c..3142ec6b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ pandid.xml pandid.trig rml/segments.trig client/.idea +.vs client/Boundaries/Dexpi2Svg/test.svg rml/C03V04.trig www/C03V04.svg diff --git a/client/Boundaries/Dexpi2Svg/Program.cs b/client/Boundaries/Dexpi2Svg/Program.cs index 0893816d..fcc5dc11 100644 --- a/client/Boundaries/Dexpi2Svg/Program.cs +++ b/client/Boundaries/Dexpi2Svg/Program.cs @@ -7,7 +7,8 @@ class Program { static void Main(string[] args) { - if(args.Length < 2) + AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);//added + if (args.Length < 2) { Console.WriteLine("Usage: dotnet run input.xml style.xslt"); return; @@ -21,10 +22,15 @@ static void Main(string[] args) xmlDoc.LoadXml(xmlData); XslCompiledTransform xslt = new XslCompiledTransform(); + XsltSettings xsltSettings = new XsltSettings(true, true);//Added + + XmlReaderSettings readerSettings = new XmlReaderSettings(); //Added + readerSettings.DtdProcessing = DtdProcessing.Parse; //added + using (StringReader sr = new StringReader(xsltData)) - using (XmlReader xr = XmlReader.Create(sr)) + using (XmlReader xr = XmlReader.Create(sr, readerSettings)) // added { - xslt.Load(xr); + xslt.Load(xr, xsltSettings, new XmlUrlResolver());//added } MathExtensions mathExtensions = new MathExtensions(); @@ -36,12 +42,16 @@ static void Main(string[] args) XmlWriterSettings settings = xslt.OutputSettings?.Clone() ?? throw new Exception("No xslt output settings found!"); settings.OmitXmlDeclaration = true; + // Transform XML to SVG + using (StringReader sr = new StringReader(xmlData))//added + using (XmlReader xr = XmlReader.Create(sr, readerSettings)) //added using (StringWriter sw = new StringWriter()) using (XmlWriter xw = XmlWriter.Create(sw, settings)) { - xslt.Transform(xmlDoc, xsltArgs, xw); - string svgOutput = sw.ToString(); + xslt.Transform(xr, xsltArgs, xw); + //xslt.Transform(xmlDoc, xsltArgs, xw); + string svgOutput = sw.ToString();//adedd // Save or use the SVG output Console.WriteLine(svgOutput); diff --git a/datalog/noaka_boundary.datalog b/datalog/noaka_boundary.datalog index 2f21c983..4c4099fe 100644 --- a/datalog/noaka_boundary.datalog +++ b/datalog/noaka_boundary.datalog @@ -8,3 +8,8 @@ data:insideBoundary [?new_node] :- data:insideBoundary [?new_node] :- data:insideBoundary [?node], imf:hasPart[?new_node, ?node] . + + +data:boundary [?new_node] :- + data:boundary [?node], + imf:hasPart[?new_node, ?node] . \ No newline at end of file diff --git a/rml_noaka/PipingNetworkSegmentConnectionTerminal.map.ttl b/rml_noaka/PipingNetworkSegmentConnectionTerminal.map.ttl index 2a9795a2..a7d5cc84 100644 --- a/rml_noaka/PipingNetworkSegmentConnectionTerminal.map.ttl +++ b/rml_noaka/PipingNetworkSegmentConnectionTerminal.map.ttl @@ -74,7 +74,7 @@ rml:iterator "//PipingNetworkSegment/Connection[not (contains(@ToID, 'Nozzle'))]" ]; rr:subjectMap [ - rr:template "https://assetid.equinor.com/plantx#{concat(@ToID, '_input')}"; + rr:template "if(@ToID) then https://assetid.equinor.com/plantx#{concat(@ToID, '_input')}"; rr:termType rr:IRI; rr:class imf:Terminal ] ; @@ -95,7 +95,7 @@ rml:iterator "//PipingNetworkSegment/Connection[not (contains(@FromID, 'Nozzle'))]" ]; rr:subjectMap [ - rr:template "https://assetid.equinor.com/plantx#{concat(@FromID, '_output')}"; + rr:template "if(@FromID) then https://assetid.equinor.com/plantx#{concat(@FromID, '_output')}"; rr:termType rr:IRI; rr:class imf:Terminal ] ; diff --git a/www/ProgramOverviewNoaka.md b/www/ProgramOverviewNoaka.md new file mode 100644 index 00000000..ad0b7464 --- /dev/null +++ b/www/ProgramOverviewNoaka.md @@ -0,0 +1,35 @@ +# Program Overview + +## Overview of XSLT Stylesheet for SVG Conversion + +This document outlines the components of the XSLT stylesheet designed to transform XML data from NOAKADexpi into a graphical SVG format. Specific templates within the stylesheet are responsible for various aspects of the SVG output. + +### SVG Structure and Design + +- **Base SVG Output (`/PlantModel` Template)**: This template is responsible for generating the foundational SVG structure, including setting the `width` and `viewBox` attributes based on the XML input. + +### Dynamic Visual Elements + +- **Matching piping linesTemplate**: This template draws SVG paths for elements like `CenterLine`, applying styles such as dashed lines to denote information flows. +- **Positioning and Transformations**: It calculates the correct positioning and rotation for SVG elements. +- **Template for PipingNetworkSystem**: Manages the creation of text labels on the lines, and its text orientation. +- **Shape Catalog Template**: defines SVG symbols. It locates the appropriate `_Origo.svg` file based on the `shapeValue` and then processes text elements, passing their values as arguments to populate text fields within the Symbol SVG. Before appyling another template to the symbols. + - **Style-Based Exclusions (`Style-Based Filtering` Section)**: Elements with specific stroke or fill colors are excluded from the output, which is a deliberate filtering process to manage the visual output when showing the symbols. + - **Direct Element Copying (`Generic Copying` Section)**: To ensure all SVG elements not explicitly matched by other templates are included in the output, a generic copying process is employed. + + +### Special Considerations and Notes + +- **Symbol Library Location**: The symbol library repo must be located in a adjacent folder to SSI-DEXPI-TEMP for the stylesheet to function correctly. +- **Shape Exclusions and Fallbacks**: + - The `BORDER_A1_Origo.svg` file does not exist, necessitating an `if` check to handle its absence. + - Since `PV001A_Origo.svg` is also missing, an empty SVG text element was created as a placeholder. + + +### Known Issues and Limitations + - Not all nozzles are present in the provided data. + + + + +--- \ No newline at end of file diff --git a/www/RunGuide.md b/www/RunGuide.md new file mode 100644 index 00000000..0d0d7f84 --- /dev/null +++ b/www/RunGuide.md @@ -0,0 +1,67 @@ +# Running the NOAKADEXPI Program + +This guide will help you run the NOAKADEXPI program that converts DEPI XML files to SVG format using the DEXPI2SVG tool. + +## Prerequisites + +Before you start, ensure that you have the following repository structure on your local machine: + +- `NOAKADEXPI` repository located adjacent to the `SSI_DEXPI_TEMP` repository. + +## Steps to Run the Program + +1. **Navigate to the Tool Directory** + + Open a command prompt or terminal window and navigate to the `Client/boundaries/Dexpi2svg` directory within the `NOAKADEXPI` repository. + +2. **Run the Conversion Command** + + Use the following command to convert your DEPI XML file to SVG format: + + ```sh + dotnet run "" "" > output.svg + ``` + + Replace `` with the generic path to your DEPI XML file and `` with the generic path to your XSLT file. + +3. **Addressing Missing Symbol Error** + + If you encounter an error about a missing symbol `PV001A_Origio.svg`, you will need to create it by following these steps: + + a. Create a new file inside the `NOAKADEXPI/SYMBOL/Origo` directory. + + b. Paste the following SVG content into the new file: + + ```xml + + + + + + + + ``` + + Name this file `PV001A_Origio.svg`. + +4. **Integrate the SVG Output** + + Once you have the `output.svg` file, you can integrate it into your `dexpi.html` file: + + a. Copy the full contents of `output.svg`. + + b. Paste the copied SVG content into `dexpi.html` after the line ``. + + Ensure that the end of your `dexpi.html` file only contains the following lines: + + ```html + + + + ``` + +5. **View the Result** + + Open `dexpi.html` in a web browser to view the SVG representation of your DEPI XML file. You should now be able to click on the components within the SVG as intended. + If you want to be able to create boundaries you must use RDFox aswell, to manage this see the README in client/boundaries. \ No newline at end of file diff --git a/www/dexpisvgNoaka.xslt b/www/dexpisvgNoaka.xslt new file mode 100644 index 00000000..cf6e6843 --- /dev/null +++ b/www/dexpisvgNoaka.xslt @@ -0,0 +1,348 @@ + + + + + + + + + + + + 0 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + M + + + + + + L + + + + + #000000 + + + + + + + + 1,4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rotate( + + , + + , + + ) + + translate( + + , + + ) + + scale + + + + + + + + + + + + + + + + + + + + + + 3.3px + Arial + middle + + + + + + + + + + 270 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + non-scaling-stroke + round + round + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/www/dexpisvg.xslt b/www/dexpisvgOld.xslt similarity index 100% rename from www/dexpisvg.xslt rename to www/dexpisvgOld.xslt