0

TEI「標準」で構造化されたxmlドキュメントがあります。おそらく知っている人もいるでしょう。これを別の XML 構造に変換する XSLT を作成しました。

しかし、私は問題に来ました。変換プロセスは、XML 構造の特定のノードに到達しません。

元のドキュメントは次のようになります。

<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:tgl="http://******/namespaces  /metadata/language/2010" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:tns="http://*****/namespaces/metadata/core/2010" xmlns:tgr="http://*****/namespaces/metadata/agent/2010" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:tgs="http://*****/namespaces/metadata/script/2010" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:id="tg397" n="/Literatur/M/Birlinger, Anton/Märchen und Sagen/Sagen, Märchen, Volksaberglauben/3./299. Von den Sternen/2. [Die Sterne halten Viele für die Köpfe silberner Nägel]">
<teiHeader xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:a="http://www.*****/namespace/digibib/authors" xmlns:fn="http://www.w3.org/2005/xpath-functions">

<fileDesc>
    <titleStmt>
    <title> hshshhshs </title>
</titleStmt>
<publicationStmt>
   ....

XSLT を使用して、いくつかのノードに到達しようとしています。そうではないので、簡単な例を試してみましたが、の内容にたどり着けません。これは XSLT です。

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

<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
    <!--<xsl:template match="/TEI">-->
 <xsl:template match="/">


        <add><doc>
            <field name="title">
                <xsl:value-of select="TEI/teiHeader/fileDesc/titleStmt/title"/>
            </field>-
        </doc></add>


 </xsl:template>
 </xsl:stylesheet>

そして、これは結果です:

 <?xml version="1.0" encoding="UTF-8"?>
   <add>
   <doc>
    <field name="title"/>-

       </doc>
   </add>

あなたの誰かが私を助けてくれることを願っています。

4

1 に答える 1

3

これは、TEI ドキュメントがこの行で始まるためです。

<TEI xmlns="http://www.tei-c.org/ns/1.0"

これは、名前空間プレフィックスで特に指定されていない限り、ドキュメント内のすべての要素が名前空間 "" http://www.tei-c.org/ns/1.0 "にあることを意味します。

ただし、XSLT ドキュメントでは、名前空間のない要素を選択しようとしているため、名前空間を持つ TEI の要素と一致しません。

解決策は、最初に XSLT ドキュメントで関連する名前空間を、好きなプレフィックスを使用して宣言することです。

<xsl:stylesheet 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:tei="http://www.tei-c.org/ns/1.0"
   version="1.0">

次に、XLSTステートメントを次のように記述できます

<xsl:value-of select="tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title"/>
于 2013-04-19T07:37:31.847 に答える