"xsi:schemaLocation="location1 location2 ..." と "xmlns:someNs" が大量に含まれる xml ファイルを取得しました。名前空間は新しいドキュメントにコピーされますが、schemaLocations はそうではなく、なぜそれらが存在するのかわかりません削除されます (すべての名前空間と schemaLocations も私のスタイルシートにあります)。
Googleは、ドキュメント内またはこのようなもので使用されていない場合は削除されると言っています。自分で追加する必要がありますが、できないようです... xalanパイプラインを使用していくつかの基本的な変換をパイプしていますが、今パイプの最後にスタイルシートを追加して、場所を再度追加しようとしています。これは私の最後のシートです:
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:attribute name="xsi:schemaLocation">
<xsl:text>MYLOCATION</xsl:text>
</xsl:attribute>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
コピーなしで要素タグを囲むいくつかのバリアントがありました...最良の結果は、schemaLocationを持つ二重化されたルート要素と、私が本当に理解できないすべての名前空間を持つものでした。
助けてくれてありがとう;)
€: xalan パイプを除いて、私の個々のスタイルシートはすべて機能しているようです。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pipe="http://xml.apache.org/xalan/PipeDocument"
extension-element-prefixes="pipe"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="someschema"
>
<xsl:param name="source"/>
<xsl:param name="target"/>
<!-- I think this block has no effect -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<pipe:pipeDocument
source="{$source}"
target="{$target}">
<stylesheet href="sheet1.xsl"/>
<stylesheet href="sheet2.xsl"/>
<stylesheet href="sheet3.xsl"/>
</pipe:pipeDocument>
</xsl:template>
</xsl:stylesheet>
Xalan は -IN および -OUT で呼び出されなくなりました。xmlns 宣言がまだ出力にある理由がわかりませんが、その場所が失われると思います。すべてのシートは独自の恒等変換を行い、パイプなしで使用すると期待どおりに機能します。