質問

I have problems transforming XML Code. I want to transform each div type="article" Element into another new file. My XML file looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!--Die Texte sind eine Abwandlung des von www.editura.de erstellten und von TextGrid weiterverarbeiteten und zur Verfügung gestellten Datenbestandes und
    werden unter der Lizenz Creative Commons Namensnennung 3.0 Deutschland Lizenz (by-Nennung TextGrid, www.editura.de)
    (http://creativecommons.org/licenses/by/3.0/de/legalcode) wiederum zur Verfügung gestellt.-->
    <TEI xmlns="http://www.tei-c.org/ns/1.0"
         xmlns:tei="http://www.tei-c.org/ns/1.0"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:svg="http://www.w3.org/2000/svg"
         xmlns:math="http://www.w3.org/1998/Math/MathML">
       <teiHeader>
          <fileDesc>
             <titleStmt>
                <title>Title</title>
             </titleStmt>
             <publicationStmt>
                <p>Publication Information</p>
             </publicationStmt>
             <sourceDesc>
                <p>Information about the source</p>
             </sourceDesc>
          </fileDesc>
       </teiHeader>
       <text>
          <body>
             <div type="article">
                <head>Abel, Ambrosius</head>
                <div type="text">
                   <p>
                      <hi rend="bold">Abel, Ambrosius</hi>. Ambrosius Abel wurde am 1. Juni 1820 geboren</p>
                   <p rend="zenoCOLit">
                      <hi rend="italics">Quellen</hi>: Verlagskatalog 1887, Börsenblatt.</p>
                </div>
             </div>

             <div type="article">
                <head>Babenzien, Max</head>
                <div type="text">
                   <p>
                      <hi rend="bold">Babenzien, Max</hi>. Während das Gründungsjahr der Buchdruckerei in das Jahr 1816 fällt, ist die Buchhandlung von <hi rend="italics">A. Haase</hi> unter dessen Namen am 1. April 1833 gegründet.</p>
                   <p rend="zenoCOLit">
                      <hi rend="italics">Quellen</hi>: Verlagskatalog 1899.</p>
                </div>
             </div>
</body>
   </text>
</TEI>

Whenever I try to transform the xml file the XSL File transformation wouldnt perform. The XSL looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:tei="http://www.tei-c.org/ns/1.0"
    version="2.0" xmlns="http://www.tei-c.org/ns/1.0">

    <xsl:output method="text"/>
    <xsl:output method="xml" indent="yes" name="xml"/>




    <xsl:template match="/">
        <xsl:for-each select="//div[@type = 'article']">
            <xsl:variable name="filename"
                select="concat('ausgabedateien/',@type,'.xml')" />
            <xsl:value-of select="$filename" />  

            <xsl:result-document href="{$filename}_{position()}" format="xml" indent="yes">

                <TEI xmlns="http://www.tei-c.org/ns/1.0"
                    xmlns:tei="http://www.tei-c.org/ns/1.0"
                    xmlns:xi="http://www.w3.org/2001/XInclude"
                    xmlns:svg="http://www.w3.org/2000/svg"
                    xmlns:math="http://www.w3.org/1998/Math/MathML">
                    <teiHeader>
                        <fileDesc>
                            <titleStmt>
                                <title>Title</title>
                            </titleStmt>
                            <publicationStmt>
                                <p>Publication Information</p>
                            </publicationStmt>
                            <sourceDesc>
                                <p>Information about the source</p>
                            </sourceDesc>
                        </fileDesc>
                    </teiHeader>
                    <text>
                        <body>

                            <xsl:copy-of select="." />

                        </body>
                    </text>
                </TEI>

            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

I tried removing the xmlns Attribute of the xml file, everything would work properly. Anyone has a solution for this problem?

役に立ちましたか?

解決

Since you are using XSLT 2.0, you can add

xpath-default-namespace="http://www.tei-c.org/ns/1.0"

to the xsl:stylesheet element.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top