1.Vstupné testovacie údaje
občiansky preukaz: OP01.xml
<?xml version="1.0" encoding="utf-8"?> <IDCardResponse> <obcianskyPreukaz> <meno>Martin</meno> <priezvisko>Straka</priezvisko> <statneObcianstvo>SVK</statneObcianstvo> <pohlavie>M</pohlavie> <datumNarodenia>2002-05-01</datumNarodenia> <rodneCislo>020501/0123</rodneCislo> <cisloPreukazu>ES12345678</cisloPreukazu> <vydal>Nitra</vydal> <datumPlatnosti>2030-10-20</datumPlatnosti> <datumVydania>2020-10-21</datumVydania> <miestoNarodenia>Praha</miestoNarodenia> <trvalyPobyt>Poprad</trvalyPobyt> <rodnePriezvisko>Straka</rodnePriezvisko> <osobitneZaznamy>abstinent</osobitneZaznamy> <fotografia>none</fotografia> <podpis>xxx</podpis> </obcianskyPreukaz> </IDCardResponse>
2.XSLT Transformácia
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:base="https://minv.gov.sk/id/id-card/" xmlns:pper="https://data.gov.sk/def/ontology/physical-person/" xmlns:lsub="https://data.gov.sk/def/ontology/legal-subject/" xmlns:egov="https://data.gov.sk/def/ontology/egovernment/" xmlns:loca="https://data.gov.sk/def/ontology/location/" xmlns:locn="https://www.w3.org/ns/locn#" xmlns:adms="http://www.w3.org/ns/adms#" xmlns:dct="http://www.w3.org/ns/adms#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:foaf="http://xmlns.com/foaf/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:schema="http://schema.org/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Global parameters --> <xsl:param name="ns">https://minv.gov.sk/id/id-card/</xsl:param> <xsl:param name="uriCountry">http://publications.europa.eu/resource/authority/country/</xsl:param> <!-- Functions --> <!-- Output --> <xsl:output encoding="UTF-8" indent="yes" method="xml" normalization-form="NFC" /> <xsl:strip-space elements="*"/> <!-- Templates --> <xsl:template match="/IDCardResponse"> <rdf:RDF><xsl:apply-templates/></rdf:RDF> </xsl:template> <xsl:template match="/IDCardResponse/obcianskyPreukaz"> <xsl:variable name="givenName" select="/IDCardResponse/obcianskyPreukaz/meno"/> <xsl:variable name="familyName" select="/IDCardResponse/obcianskyPreukaz/priezvisko"/> <xsl:variable name="givenFamilyName" select="/IDCardResponse/obcianskyPreukaz/rodnePriezvisko"/> <xsl:variable name="specialRecords" select="/IDCardResponse/obcianskyPreukaz/osobitneZaznamy"/> <xsl:variable name="portraitBase64" select="/IDCardResponse/obcianskyPreukaz/fotografia"/> <xsl:variable name="signatureBase64" select="/IDCardResponse/obcianskyPreukaz/podpis"/> <xsl:variable name="dateOfBirth" select="/IDCardResponse/obcianskyPreukaz/datumNarodenia"/> <xsl:variable name="birthNumberCode" select="/IDCardResponse/obcianskyPreukaz/rodneCislo"/> <xsl:variable name="citizenship" select="/IDCardResponse/obcianskyPreukaz/statneObcianstvo"/> <xsl:variable name="sex" select="/IDCardResponse/obcianskyPreukaz/pohlavie"/> <xsl:variable name="placeOfBirth" select="/IDCardResponse/obcianskyPreukaz/miestoNarodenia"/> <xsl:variable name="permanentResidency" select="/IDCardResponse/obcianskyPreukaz/trvalyPobyt"/> <xsl:variable name="issued" select="/IDCardResponse/obcianskyPreukaz/datumVydania"/> <xsl:variable name="validUntil" select="/IDCardResponse/obcianskyPreukaz/datumPlatnosti"/> <xsl:variable name="publisherName" select="/IDCardResponse/obcianskyPreukaz/vydal"/> <xsl:variable name="id" select="/IDCardResponse/obcianskyPreukaz/cisloPreukazu"/> <xsl:variable name="uri" select="concat(ns, id)"/> <pper:IDCard rdf:about="{concat($ns, $id)}"> <adms:identifier> <adms:Identifier> <skos:notation rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><xsl:value-of select="$id"/></skos:notation> <dct:type> <egov:IdentifierType rdf:about="https://data.gov.sk/def/identifier-type/1"> <skos:prefLabel xml:lang="sk">Identifikátor zahraničnej služobnej cesty</skos:prefLabel> <skos:inScheme rdf:resource="https://data.gov.sk/set/codelist/CL004001"/> </egov:IdentifierType> </dct:type> <egov:issuingCountry> <loca:UNCountry rdf:about="http://publications.europa.eu/resource/authority/country/SVK"> <skos:prefLabel xml:lang="sk">Slovenská republika</skos:prefLabel> <skos:notation xml:lang="sk">SVK</skos:notation> <skos:inScheme rdf:resource="http://publications.europa.eu/resource/authority/country"/> </loca:UNCountry> </egov:issuingCountry> <dct:publisher> <lsub:LegalSubject> <skos:prefLabel xml:lang="sk"><xsl:value-of select="$publisherName"/></skos:prefLabel> </lsub:LegalSubject> </dct:publisher> <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$issued"/></dct:issued> <schema:validUntil rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$validUntil"/></schema:validUntil> </adms:Identifier> </adms:identifier> <dct:rightsHolder> <pper:PhysicalPerson> <foaf:givenName xml:lang="sk"><xsl:value-of select="$givenName"/></foaf:givenName> <foaf:familyName xml:lang="sk"><xsl:value-of select="$familyName"/></foaf:familyName> <foaf:givenFamilyName xml:lang="sk"><xsl:value-of select="$givenFamilyName"/></foaf:givenFamilyName> <pper:dateOfBirth rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$dateOfBirth"/></pper:dateOfBirth> <pper:birthNumberCode rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$birthNumberCode"/></pper:birthNumberCode> <pper:placeOfBirth> <locn:Location> <skos:prefLabel xml:lang="sk"><xsl:value-of select="$placeOfBirth"/></skos:prefLabel> </locn:Location> </pper:placeOfBirth> <pper:citizenship> <loca:UNCountry rdf:about="{concat($uriCountry, $citizenship)}"> <skos:notation xml:lang="sk"><xsl:value-of select="$citizenship"/></skos:notation> <skos:inScheme rdf:resource="http://publications.europa.eu/resource/authority/country"/> </loca:UNCountry> </pper:citizenship> <pper:permanentResidency> <loca:PhysicalAddress> <locn:fullAddress xml:lang="sk"><xsl:value-of select="$permanentResidency"/></locn:fullAddress> </loca:PhysicalAddress> </pper:permanentResidency> <egov:portraitBase64 rdf:datatype="http://www.w3.org/2001/XMLSchema#base64Binary"><xsl:value-of select="$portraitBase64"/></egov:portraitBase64> <egov:signatureBase64 rdf:datatype="http://www.w3.org/2001/XMLSchema#base64Binary"><xsl:value-of select="$signatureBase64"/></egov:signatureBase64> <pper:specialRecords rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><xsl:value-of select="$specialRecords"/></pper:specialRecords> <xsl:choose> <xsl:when test="$sex = 'M'"> <pper:sex rdf:resource="https://data.gov.sk/def/sex/01"/> </xsl:when> <xsl:when test="$sex = 'W'"> <pper:sex rdf:resource="https://data.gov.sk/def/sex/02"/> </xsl:when> </xsl:choose> </pper:PhysicalPerson> </dct:rightsHolder> </pper:IDCard> </xsl:template> <!-- Catch-all empty template --> <xsl:template match="text()|@*" mode="#all"/> </xsl:stylesheet>
Výsledné RDF: Usmernenie: JSON-LD API pre Občiansky preukaz
Pridať komentár