私は1つの非常に複雑なXMLファイルを持っていて、複雑なXMLファイルをいくつか修正しています。複雑なものから XSLT - 2つのXMLファイルを比較して組み合わせる
一つの要素:単純なものから
<h1:Document DocKey="obj 40020528">
<h1:Block Type="obj"
CreationDate="20.03.2014 09:39:50"
CreatorID="Admin"
ChangeDate="21.01.2015 14:40:51"
ChangerID="Admin"
OwnerID="Admin"
FieldsCount="17">
<h1:Field Type="5000" Value="40020528"/>
<h1:Field Type="5060" Value="Aufnahme">
<h1:Field Type="5064" Value="unbekannt"/>
</h1:Field>
<h1:Field Type="ob28" Value="Verwalter">
<h1:Field Type="2864" Value="Köln"/>
<h1:Field Type="2900"
Value="Theaterwissenschaftliche Sammlung, Universität zu Köln"/>
<h1:Field Type="2930" Value="Fotoabteilung"/>
<h1:Field Type="2950" Value="TWS_FGL00541"/>
<h1:Field Type="907d" Value="No: 4260"/>
</h1:Field>
<h1:Field Type="ob26" Value="Aufnahmeort">
<h1:Field Type="2664" Value="unbekannt"/>
<h1:Field Type="2690" Value="Theater"/>
<h1:Field Type="2700" Value="Theater unbekannt"/>
</h1:Field>
<h1:Field Type="ob30" Value="Herstellung">
<h1:Field Type="3100" Value="unbekannt"/>
<h1:Field Type="3475" Value="Fotograf/in, Atelier"/>
</h1:Field>
<h1:Field Type="5007" Value="Darstellung">
<h1:Field Type="5009" Value="unbekannt"/>
<h1:Field Type="5010" Value="Autor/in"/>
<h1:Field Type="5013" Value="xTITELx"/>
</h1:Field>
<h1:Field Type="ob40" Value="Inszenierung">
<h1:Field Type="4100" Value="unbekannt"/>
<h1:Field Type="4475" Value="Regie"/>
</h1:Field>
<h1:Field Type="ob40" Value="Inszenierung">
<h1:Field Type="4100" Value="unbekannt"/>
<h1:Field Type="4475" Value="Bühnenbild"/>
</h1:Field>
<h1:Field Type="5200" Value="Fritz Feinhals"/>
<h1:Field Type="5220" Value="Fotografie"/>
<h1:Field Type="5230" Value="Negativ"/>
<h1:Field Type="5240" Value="Glasplattennegativ"/>
<h1:Field Type="5360" Value="18x13"/>
<h1:Field Type="55th" Value="Feinhals, Fritz"/>
</h1:Block>
</h1:Document>
一つの要素:
<signatur id="TWS_FGL00541">
<datum/>
<ort/>
<ortsteil/>
<titel>Fritz Feinhals als Wotan</titel>
<fotograf/>
<komponist>Wagner, Richard</komponist>
<author/>
<regie/>
<buehnenbild/>
<darPerson/>
<freiText>Walküre</freiText>
</signatur>
私は「Signatur」ごとに2つの文書の要素を比較しようとしています。署名が同じであれば、修正があります。修正がある場合、単純なXMLのどの子要素を複合要素の子要素に入れなければならないかをチェックする必要があるため、単純な要素の子要素に値があるかどうかをチェックする必要があります。そのように、値は複雑な要素の特定の要素に置かれなければなりません。
私はそれを行うための最良の方法は何も知らない。次のように私のような何かをしようとしていた。
<xsl:template name="alles" match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:variable name="Halft" select="document('simpleOne.xml')" />
<xsl:variable name="Sig_Halft" select="preceding-sibling::$Halft/document/signatur" />
<xsl:variable name="Sig_HiDA" select="preceding-sibling::DocumentSet/Document/Block/Field[@Type='ob28']/Field[@Type='2950']/@Value" />
<!-- <xsl:variable name="" select="" /> -->
<xsl:template match="DocumentSet/Document">
<xsl:if test="$Sig_HiDA = $Sig_Halft"> <!-- wenn signatur gleich -->
xcbcvncvn
<!-- Datum -->
<xsl:if test="((DocumentSet/Document/Block/Field[@Type='5060']/Field[@Type='5064']/@Value != '') or (DocumentSet/Document/Block/Field[@Type='5060']/Field[@Type='5064']/@Value != $Halft/document/signatur/datum))">
</xsl:if>
<!-- Ort -->
<xsl:if test="((DocumentSet/Document/Block/Field[@Type='ob26']/Field[@Type='2664']/@Value != '') or (DocumentSet/Document/Block/Field[@Type='ob26']/Field[@Type='2664']/@Value != $Halft/document/signatur/ort))">
</xsl:if>
<!-- Ortsteil(Theater) -->
<xsl:if test="((DocumentSet/Document/Block/Field[@Type='ob26']/Field[@Type='2700']/@Value != '') or (DocumentSet/Document/Block/Field[@Type='ob26']/Field[@Type='2700']/@Value != $Halft/document/signatur/ortsteil))">
</xsl:if>
<!-- Titel -->
<xsl:if test="((DocumentSet/Document/Block/Field[@Type='5200']/@Value != '') or (DocumentSet/Document/Block/Field[@Type='5200']/@Value != $Halft/document/signatur/titel))">
<h1:Field Type="5200" Value="{$Halft/document/signatur/titel}"/>
</xsl:if>
<!-- Fotograf -->
<xsl:if test="((DocumentSet/Document/Block/Field[@Type='ob30']/Field[@Type='3100']/@Value != '') or (DocumentSet/Document/Block/Field[@Type='ob30']/Field[@Type='3100']/@Value != $Halft/document/signatur/fotograf))">
</xsl:if>
<!-- Komponist -->
<xsl:if test="((DocumentSet/Document/Block/Field[@Type='5007']/Field[@Type='5009']/@Value != '') or (DocumentSet/Document/Block/Field[@Type='5007']/Field[@Type='5009']/@Value != $Halft/document/signatur/komponist))">
</xsl:if>
</xsl:if>
</xsl:template>
残念ながら、サンプル入力XMLとサンプルXSLコードはすぐには関係がありません.XSLにはXMLの何も一致しません。 [ヘルプセンター](https://stackoverflow.com/help)の[**最小限で完全で検証可能なサンプルを作成する方法**](https://stackoverflow.com/help/mcve)の記事をお読みください。 )それに応じてあなたの投稿を修正してください。 –
アドバイスをいただきありがとうございますが、私は彼らがいかに即座の関係を示していないかを理解できないと言わなければなりません。私のxslの何もXMLの何にもマッチしないとどう思いますか?変数とif文で、両方のXMLファイルの要素の式がわかります。あなたのコメントを見た後、私の修正から、私は、単に例のxmlファイルで言及していないと言うことができます。それらは親要素 "DocumentSet"(複雑なもの)と "Document" ) 上に示しました。 –
Re:一致しない: 'DocumentSet/Document'は何もマッチしません。なぜなら、1)サンプル入力XMLに' DocumentSet'要素がないので、 'Document'子は存在しません。 2)デフォルトの名前空間で 'Document'にマッチしたとしても、入力されたXMLはデフォルト以外の名前空間に' h1:Document'しかありません。ネームスペースと接頭辞は、XML処理の重要かつ難しい部分です。 XMLを使って多くのことを作業する場合は、これらの記事を読むのに役立つかもしれません。 –