0
我的XML文件中像比較XSL輸出
<section>
<dlentry xtrf="books.xml">
<dd>
<msgph>Harry Potter
</msgph>
</dd>
</dlentry>
<dlentry xtrf="books.xml">
<dd>
<msgph>1984
</msgph>
</dd>
</dlentry>
<dlentry xtrf="books.xml">
<dd>
<msgph>The Great Gatsby
</msgph>
</dt>
</dlentry>
<dlentry>
<dd>
<dl>
<dlentry xtrf="myFavouriteBooks.xml">
<dd>
<parml>
<plentry>
<pd>
<msgph>Harry Potter
</msgph>
</pd>
</plentry>
</parml>
</dd>
</dlentry>
</dl>
</dd>
</dlentry>
<dlentry xtrf="myBooks.xml">
<dd>
<msgph>1984
</msgph>
</dd>
</dlentry>
</section>
而我需要的是使用XSL創建2所列出,首先要做的是什麼? - 與具有ID「dlentry」元素的值=」 books.xml「和第二個 - 與id =」books.xml「。之後我應該比較這些名單,並給所有不匹配的元素注意消息。 「!!!!!注意MISSING 1984年 MISSING 了不起的蓋茨比」
喜歡的東西
現在我的xsl:
<xsl:variable name="inBooks" select="/dlentry/dd/msgph"/>
<xsl:variable name="notInBooks" select="//dlentry[not(contains(@xtrf,'books.xml))]//msgph/node()[not(self::dlentry)])" as="item()*"/>
<title>Books</title>
<refbody>
<section>
<dl>
<dlentry>
<xsl:variable name="notMatched" select="//dlentry[not(contains(@xtrf,'books.xml'))]//msgph[msgph !='$inBooks']/node()[not(self::dlentry)])"/>
<xsl:choose>
<xsl:when test="$notMatched">
<xsl:for-each select="section/dl/dlentry">
<dt>
<xsl:value-of select="concat('!MISSING! ', msgph")/>
</dt>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="section/dl/dlentry">
<dt>
<xsl:value-of select="msgph"/>
</dt>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<dt>
<xsl:value-of select="$notInBooks"/>
</dt>
<../>
,它給輸出:
<title>Books</title>
<refbody>
<section>
<dl>
<dlentry>
<dt>The Great Gatsby</dt>
<dt>1984</dt>
<dt>Harry Potter Part 2</dt>
<dt>Harry Potter Part 1</dt>
<dd/>
<dt>Harry Potter Part 1 Harry Potter Part 2</dt>
</..>
我試過數百個組合ns,但它不起作用..現在它應該添加「!MISSING!」到一個名單「id =書籍」,但它只給出一個空的元素 你能指出我,我的錯誤在哪裏,請問?
你可以發佈一個最小的,但良好的XML輸入樣?如果諸如「哈利波特第1部分 」這樣的標記不完整,我恐怕很難理解你想要比較的東西。我也猜你想要使用'msgph!= $ inBooks'。 –
我已經更改了xsl,現在它包含了解釋我正在處理的最低信息 – Angela
並感謝您的反饋!我但我不明白我怎麼可以使用'msgph!= $ inBooks'..我沒有經驗與xsl,但似乎不可能..作爲'msgph'不在同一位置 – Angela