Skip to content

Commit

Permalink
Correctie op MIM serialisatie en RDF
Browse files Browse the repository at this point in the history
De RDF output had geen goede representatie van generalisatie relaties.
Deze is nu toegevoegd.

Ook zijn de ID's nu "leesbaar" in plaats van de EA UUID. Dit zal wanneer
gewenst een keuze worden (via property).

Zie #558

Bugfix.
  • Loading branch information
arjan authored and arjan committed Nov 12, 2024
1 parent 46a1de2 commit 28647ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/main/java/nl/imvertor/MIMCompiler/MIMCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ public boolean generateDefault() throws Exception {
}

if (isRDFType) {
transformer.setXslParm("generate-readable-ids", "false");
transformer.setXslParm("generate-readable-ids", "true");
transformer.setXslParm("generate-all-ids", "true");
}
transformer.setXslParm("add-generated-id", "true");
}

succeeds = succeeds && transformer.transformStep("properties/WORK_EMBELLISH_FILE", "properties/WORK_MIMFORMAT_XMLPATH", xslFileParam); //TODO must relocate generation of WORK_LISTS_FILE to a EMBELLISH step.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Zie: https://docs.geostandaarden.nl/mim/mim/ voor de laatste versie van de stand

<xsl:template match="mim-in:Informatiemodel|mim-in:Domein|mim-in:View|mim-in:Extern|mim-in:Attribuutsoort|mim-in:Objecttype|mim-in:Gegevensgroep|mim-in:Gegevensgroeptype|
mim-in:PrimitiefDatatype|mim-in:GestructureerdDatatype|mim-in:Enumeratie|mim-in:Referentielijst|mim-in:Codelijst|mim-in:DataElement|mim-in:Enumeratiewaarde|
mim-in:ReferentieElement|mim-in:Constraint|mim-in:Keuze|mim-in:ExterneKoppeling|mim-in:Interface|mim-in:Relatiesoort|mim-in:Bron|mim-in:Doel|mim-in:Relatieklasse">
mim-in:ReferentieElement|mim-in:Constraint|mim-in:Keuze|mim-in:ExterneKoppeling|mim-in:Interface|mim-in:Relatiesoort|mim-in:Bron|mim-in:Doel|mim-in:Relatieklasse|mim-in:GeneralisatieObjecttypen|mim-in:GeneralisatieDatatypen">
<xsl:element name="mim:{local-name()}">
<xsl:attribute name="rdf:about" select="local:get-id(.)"/>
<xsl:apply-templates select="mim-in:*[xhtml:* or (not(*) and normalize-space())]" mode="metagegeven"/>
<xsl:apply-templates select="(mim-in:packages|mim-in:datatypen|mim-in:objecttypen|mim-in:gegevensgroeptypen|mim-in:keuzen|mim-in:interfaces|mim-in:attribuutsoorten|mim-in:relatiesoorten|mim-in:relatierollen|mim-in:relatieklasse|
mim-in:gegevensgroepen|mim-in:externeKoppelingen|mim-in:constraints|mim-in:dataElementen|mim-in:enumeratiewaarden|mim-in:referentieElementen|mim-in:bron|mim-in:doel|
mim-in:type|mim-in:gegevensgroepType)/*" mode="metagegeven"/>
mim-in:type|mim-in:gegevensgroepType|mim-in:supertype)/*" mode="metagegeven"/>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
Expand Down Expand Up @@ -186,7 +186,7 @@ Zie: https://docs.geostandaarden.nl/mim/mim/ voor de laatste versie van de stand
<mim:relatieklasse rdf:resource="{local:get-id(.)}"/>
</xsl:template>

<xsl:template match="(mim-in:GeneralisatieObjecttypes|mim-in:GeneralisatieDatatypes)[mim-in:supertype/mim-ref:*]">
<xsl:template match="(mim-in:GeneralisatieObjecttypen|mim-in:GeneralisatieDatatypen)[mim-in:supertype/mim-ref:*]">
<mim:Generalisatie rdf:about="{local:get-id(.)}">
<xsl:apply-templates select="mim-in:*[xhtml:* or (not(*) and normalize-space())]" mode="metagegeven"/>
<mim:subtype rdf:resource="{local:get-id(ancestor::mim-in:*[@id][1])}"/>
Expand Down
16 changes: 9 additions & 7 deletions src/main/resources/xsl/MIMCompiler/v2/MIM1.2/MIMCompiler.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<xsl:mode name="missing-metadata"/>

<xsl:param name="generate-readable-ids" select="'true'" as="xs:string"/>
<xsl:param name="generate-all-ids" select="'false'" as="xs:string"/>
<xsl:param name="add-generated-id" select="'false'" as="xs:string"/>
<xsl:param name="generate-all-ids" select="'true'" as="xs:string"/>
<xsl:param name="add-generated-id" select="'true'" as="xs:string"/>

<xsl:variable name="runs-in-imvertor-context" select="not(system-property('install.dir') = '')" as="xs:boolean" static="yes"/>
<xsl:variable name="add-xlink-id" select="true()"/>
Expand Down Expand Up @@ -1342,9 +1342,8 @@

<xsl:function name="imf:create-id" as="xs:string">
<xsl:param name="elem" as="element()"/>
<xsl:variable name="package" select="imf:valid-id($elem/ancestor-or-self::*[self::mim:Domein|self::mim:View|self::Extern]/mim:naam)" as="xs:string?"/>
<xsl:variable name="modelelement" select="local-name($elem)" as="xs:string"/>
<xsl:variable name="naam" select="imf:valid-id($elem/mim:naam)" as="xs:string?"/>
<xsl:variable name="ancestors" select="$elem/ancestor-or-self::*/mim:naam" as="element()*"/>
<xsl:variable name="naam" select="$elem/mim:naam" as="element()?"/>
<xsl:variable name="naam" as="xs:string">
<xsl:choose>
<xsl:when test="$naam">
Expand All @@ -1355,7 +1354,10 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="lower-case(string-join(($package, $modelelement, $naam, if ($add-generated-id = 'true') then generate-id($elem) else ()), '-'))"/>
<xsl:value-of select="string-join((
for $n in $ancestors return imf:valid-id($n),
if ($add-generated-id = 'true') then generate-id($elem) else ()
), '-')"/>
</xsl:function>

<xsl:function name="imf:clean-id" as="xs:string">
Expand All @@ -1365,7 +1367,7 @@

<xsl:function name="imf:valid-id" as="xs:string?">
<xsl:param name="id" as="xs:string?"/>
<xsl:sequence select="if ($id) then replace(replace(lower-case(normalize-space($id)), '[^a-z0-9 ]', ''), ' ', '-') else ()"/>
<xsl:sequence select="if ($id) then replace(lower-case($id), '[^a-z0-9]', '') else ()"/>
</xsl:function>

<xsl:function name="imf:generate-id-attr" as="attribute()?">
Expand Down

0 comments on commit 28647ea

Please sign in to comment.