我在 xslt 转换中遇到了一些奇怪的问题,这可能是一个真正的问题,或者可能只是我忘记了一些东西。任何附加了 xsl:apply-templates 的东西都会导致空白,我不明白为什么。
我使用的xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<TEI.2>
<teiHeader>
<fileDesc>
<titleStmt>
<title>William of Palerne: An Electronic Edition</title>
<author>Anonymous</author>
<editor>Edited by G. H. V. Bunt</editor>
<respStmt>
<resp>
<hi rend="bold">Computer Consultants and Programmers</hi>
</resp>
<name> Susan Gants, Susan Munson, Daniel Pitti, and John Unsworth.</name>
</respStmt>
</titleStmt>
</fileDesc>
</teiHeader>
</TEI>
我申请的xslt如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="xs tei"
version="2.0">
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="TEI.2">
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<xsl:apply-templates/>
</TEI>
</xsl:template>
<xsl:template match="teiHeader">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
我希望我的结果是 TEI.2 转换为 TEI 并添加了命名空间的原始 XML:
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>William of Palerne: An Electronic Edition</title>
<author>Anonymous</author>
<editor>Edited by G. H. V. Bunt</editor>
<respStmt>
<resp>
<hi rend="bold">Computer Consultants and Programmers</hi>
</resp>
<name> Susan Gants, Susan Munson, Daniel Pitti, and John Unsworth.</name>
</respStmt>
</titleStmt>
</fileDesc>
</teiHeader>
</TEI>
相反,TEI.2 按预期更改为 TEI,但 teiHeader 未出现:
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<fileDesc xmlns="">
<titleStmt>
<title>William of Palerne: An Electronic Edition</title>
<author>Anonymous</author>
<editor>Edited by G. H. V. Bunt</editor>
<respStmt>
<resp>
<hi>Computer Consultants and Programmers</hi>
</resp>
<name> Susan Gants, Susan Munson, Daniel Pitti, and John Unsworth.</name>
</respStmt>
</titleStmt>
</fileDesc>
</TEI>
我确定我犯了错误或忽略了某些东西,但我终其一生都无法弄清楚它是什么。如果有人能告诉我什么让我搞砸了以及如何纠正它,我将不胜感激。