1

メタデータ スキーマを持たない 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>
4

2 に答える 2

0

pbcoreRightsSummary 要素の名前空間を定義する必要があります。XSLT は、デフォルトで null 名前空間に一致します (XML ドキュメントの「接頭辞のない」名前空間には一致しません)。

于 2013-09-11T15:40:27.790 に答える
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>
于 2013-09-11T19:48:39.000 に答える