0

copy-namespaces = "no"が、XSLTの出力ドキュメントで参照されていない名前空間宣言を削除しないのはなぜですか?MarkLogic5XSLTプロセッサを使用しています。

サンプル入力

<root xmlns:temp="http://temp" xmlns:keep="http://keep">
  <wrapper><temp:x>A</temp:x>BC<temp:x>D</temp:x></wrapper>
  <keep:me>XYZ</keep:me>
</root>

サンプルXSL

<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:temp="http://temp"
  xmlns:keep="http://keep"
  exclude-result-prefixes="#all">

<xsl:template match="node()|@*" priority="-1" mode="#all">
    <xsl:copy copy-namespaces="no">
        <xsl:apply-templates select="@*|node()" mode="#current"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="temp:x">
  <xsl:apply-templates />
</xsl:template>

</xsl:stylesheet>

期待される出力

<root xmlns:keep="http://keep">
  <wrapper>ABCD</wrapper>
  <keep:me>XYZ</keep:me>
</root>

実際の出力

<root xmlns:temp="http://temp" xmlns:keep="http://keep">
  <wrapper>ABCD</wrapper>
  <keep:me>XYZ</keep:me>
</root>
4

1 に答える 1

3

これがバグであることをMarkLogicサポートに確認し、修正に取り組んでいます。

当面の間、回避策としてIDテンプレートの代わりにこれらのテンプレートを使用しています。

<xsl:template match="*" priority="-1" mode="#all">
    <xsl:element name="{name(.)}">
        <xsl:apply-templates select="@*|node()" mode="#current"/>
    </xsl:element>
</xsl:template>

<xsl:template match="@*" priority="-1" mode="#all">
    <xsl:attribute name="{name(.)}" select="."/>
</xsl:template>

<xsl:template match="comment()|processing-instruction()|text()" priority="-1" mode="#all">
    <xsl:copy/>
</xsl:template>
于 2012-09-14T18:43:40.877 に答える