我已经能够在没有元数据架构的xml文档中使用此公式将'pbcoreRightsSummary'标记成功更改为'notes':
<?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"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="pbcoreRightsSummary">
<notes>
<xsl:apply-templates select="node()|@*"/>
</notes>
</xsl:template>
</xsl:stylesheet>
但是当我将它应用于具有这些规范的文档时:
xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html
http://pbcore.org/xsd/pbcore-2.0.xsd"
我一无所获。请指教?
UPDATE:
所以,我将命名空间添加到XSLT中,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html http://pbcore.org/xsd/pbcore-2.0.xsd">
<xsl:output method="xml"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="pbcoreRightsSummary">
<notes>
<xsl:copy-of select="node()|@*"/>
</notes>
</xsl:template>
</xsl:stylesheet>
但我似乎无法改变这个文档(我使用Oxygen XML Editor 14.0):
<?xml version="1.0" encoding="utf-8"?>
<pbcoreCollection xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html http://pbcore.org/xsd/pbcore-2.0.xsd">
<pbcoreDescriptionDocument>
<pbcoreAssetType>Media Object</pbcoreAssetType>
<pbcoreAssetDate dateType="Created">1970</pbcoreAssetDate>
<pbcoreIdentifier source="CAVPP" annotation="Object Identifier">000028</pbcoreIdentifier>
<pbcoreTitle titleType="Main">Case for Population Control</pbcoreTitle>
<pbcoreTitle titleType="Series"/>
<pbcoreDescription/>
<pbcoreRightsSummary>
<rightsSummary annotation="Copyright Statement">Digital recordings from this collection may be accessed freely. </rightsSummary>
</pbcoreRightsSummary>
</pbcoreDescriptionDocument>
</pbcoreCollection>
答案 0 :(得分:0)
您需要为pbcoreRightsSummary元素定义命名空间。默认情况下,XSLT与null命名空间匹配(而不是XML文档中的'无前缀'命名空间)。
答案 1 :(得分:0)
尝试下一个XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xmlns:foo="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html http://pbcore.org/xsd/pbcore-2.0.xsd">
<xsl:output method="xml"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="foo:pbcoreRightsSummary">
<xsl:element name="notes">
<xsl:copy-of select="node()|@*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>