1

次の XML があります。

<?xml version="1.0"?>
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml" id="new" cnxml-version="0.7" module-id="new">

<metadata xmlns:md="http://cnx.rice.edu/mdml"
      mdml-version="0.5">

    <md:abstract>By the end of this section, you will be able to:
        <list>
            <item>Discuss the role of homeostasis in healthy functioning</item>
            <item>Contrast negative and positive feedback, giving one physiologic example of each mechanism</item>
        </list>
    </md:abstract>

テンプレートをmd:abstract要素に適用する必要があります。次の XSL コードがあります。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:md="http://cnx.rice.edu/mdml/0.4">

<xsl:output omit-xml-declaration="yes" encoding="ASCII"/>

<xsl:template match="c:document">
<body>
    <xsl:apply-templates select="c:metadata"/>
    <xsl:apply-templates select="c:content"/>
</body>
</xsl:template>

<xsl:template match="c:metadata">
    <xsl:apply-templates select="md:abstract"/>
</xsl:template>

<xsl:template match="md:abstract">
    <xsl:apply-templates select="@*|node()"/>
</xsl:template>

残念ながら、md:abstract要素をキャプチャしません。私は理解できません、望むのは間違っています。

4

1 に答える 1

2

あなたのドキュメントにはxmlns:md="http://cnx.rice.edu/mdml"、XSLT には がありますxmlns:md="http://cnx.rice.edu/mdml/0.4"。これらは同じではありません。名前空間は、一致するために字句的に同一でなければなりません (エイリアシングやスーパークラス化はありません)。

私自身、バージョン管理された名前空間を管理しようとしてこれを経験しましたが、それは悪夢です。あなたの例のように失敗するか、すべてのバージョンに対して明示的にチェックすることになります。それがあなたの名前空間である場合は、バージョンを削除してください。

設計している場合は、(XSLT 変換が行うように) いつでも別の属性にバージョンを入れることができます。

于 2013-08-06T12:47:50.240 に答える