Skip to content
Snippets Groups Projects
Commit 6238ed10 authored by pdler's avatar pdler
Browse files

added xlst kram

parent 6fc0e29e
Branches
No related tags found
No related merge requests found
test.py 0 → 100644
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from lxml import builder
from lxml import etree
xml_input = etree.parse("./mkg_lido--mkgddb-sub-hack-profil_20170310.xml")
xslt_root = etree.parse("./test.xsl")
transform = etree.XSLT(xslt_root)
newdom = transform(xml_input)
f = file('/home/dominik/Arbeitsfläche/xml-Projekt/test.xml', 'w')
#f.write(buffer)
print >>f, etree.tostring(newdom, pretty_print=True)
f.close()
\ No newline at end of file
test.xml 0 → 100644
This diff is collapsed.
test.xsl 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lido="http://www.lido-schema.org">
<xsl:strip-space element="root" />
<xsl:output method="xml"/>
<!-- Root -->
<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<!-- einzelne Objekte -->
<xsl:template match="lido:lido">
<xsl:choose>
<xsl:when test="./lido:descriptiveMetadata/lido:objectClassificationWrap/lido:objectWorkTypeWrap/lido:objectWorkType/lido:term[contains(@lido:pref, 'preferred')] = 'Holzschnitt'">
<object>
<xsl:apply-templates/>
</object>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ID -->
<xsl:template match="lido:lidoRecID">
<recID><xsl:value-of select="."/></recID>
</xsl:template>
<xsl:template match="lido:conceptID">
</xsl:template>
<!-- Metadaten -->
<xsl:template match="lido:descriptiveMetadata">
<descriptiveMetadata>
<xsl:apply-templates/>
</descriptiveMetadata>
</xsl:template>
<!-- Objektdaten Material -->
<xsl:template match="lido:objectClassificationWrap">
<objectClassificationWrap>
<xsl:apply-templates/>
</objectClassificationWrap>
</xsl:template>
<xsl:template match="lido:objectWorkTypeWrap">
<objectWorkTypeWrap>
<xsl:apply-templates/>
</objectWorkTypeWrap>
</xsl:template>
<xsl:template match="lido:objectWorkType">
<objectWorkType>
<xsl:apply-templates/>
</objectWorkType>
</xsl:template>
<xsl:template match="lido:term">
<term>
<xsl:value-of select="."/>
</term>
</xsl:template>
<!-- Objektdaten Inhalt -->
<xsl:template match="lido:objectIdentificationWrap">
<objectIdentificationWrap>
<xsl:apply-templates/>
</objectIdentificationWrap>
</xsl:template>
<xsl:template match="lido:titleWrap/lido:titleSet/lido:appellationValue">
<title>
<xsl:value-of select="."/>
</title>
</xsl:template>
<xsl:template match="lido:inscriptionsWrap"/>
<xsl:template match="lido:repositoryWrap"/>
<xsl:template match="lido:objectDescriptionWrap/lido:objectDescriptionSet/lido:descriptiveNoteValue">
<description>
<xsl:value-of select="."/>
</description>
</xsl:template>
<xsl:template match="lido:objectMeasurementsWrap/lido:objectMeasurementsSet/lido:displayObjectMeasurements">
<measurements>
<xsl:value-of select="."/>
</measurements>
</xsl:template>
<!-- event -->
<xsl:template match="lido:eventWrap/lido:eventSet/lido:event">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="lido:eventType"/>
<!-- Künstler -->
<xsl:template match="lido:eventActor">
<actor>
<xsl:value-of select="lido:displayActorInRole"/>
</actor>
<actorID>
<xsl:value-of select="lido:actorInRole/lido:actor/lido:actorID"/>
</actorID>
<geboren>
<xsl:value-of select="lido:vitalDatesActor/lido:earliestDate"/>
</geboren>
<gestorben>
<xsl:value-of select="lido:vitalDatesActor/lido:latestDate"/>
</gestorben>
</xsl:template>
<!-- Datum -->
<xsl:template match="lido:eventDate">
<datum>
<xsl:value-of select="lido:displayDate"/>
</datum>
</xsl:template>
<!-- Ort -->
<xsl:template match="lido:eventPlace">
<ort>
<xsl:value-of select="lido:displayPlace"/>
</ort>
</xsl:template>
<xsl:template match="lido:eventMaterialsTech"/>
<xsl:template match="lido:administrativeMetadata">
<recordInfo>
<xsl:value-of select="lido:recordWrap/lido:recordInfoSet/lido:recordInfoLink"/>
</recordInfo>
<bildLink>
<xsl:value-of select="lido:resourceWrap/lido:resourceSet/lido:resourceRepresentation/lido:linkResource"/>
</bildLink>
</xsl:template>
</xsl:stylesheet>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment