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