XSLTWrapper.scala 1.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
package utilities

import javax.xml.transform.Transformer

object XSLTWrapper {

  val TRANSFORMERIMPL = "net.sf.saxon.TransformerFactoryImpl"
  val EDM_namespace = "resources/recordnscreation.xsl"

  lazy val edmNamespaceTransformer: Transformer = {
    new TemplateCreator(TRANSFORMERIMPL, EDM_namespace).createTransformerFromResource
  }

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  def templatefromString: String =
    """<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
      |                xmlns:fn="http://www.w3.org/2005/xpath-functions"
      |                exclude-result-prefixes="fn">
      |    <!--xmlns:fn="http://www.w3.org/2005/xpath-functions"> -->
      |
      |    <xsl:output method="xml"
      |                encoding="UTF-8"
      |                indent="yes"
      |                omit-xml-declaration="yes"
      |    />
      |
      |    <!--
      |    <xsl:attribute-set name="edm">
      |        <xsl:attribute name="edm">https://europeana.org/irgendwas</xsl:attribute>
      |    </xsl:attribute-set>
      |    -->
      |    <xsl:template match="record">
      |
      |        <xsl:element  namespace="https://europeana.org/irgendwas"  name="edm:{local-name()}">
      |
      |
      |            <xsl:apply-templates select="@*|node()"/>
      |        </xsl:element>
      |
      |
      |    </xsl:template>
      |
      |
      |    <xsl:template match="@*|node()">
      |        <xsl:copy-of select="."/>
      |    </xsl:template>
      |
      |</xsl:stylesheet>
      |
      |
      |""".stripMargin

52
}