Как выбрать или удалить узел xml с помощью XSLT? Я хочу выбрать category
Узел, сравнив startDate и enddate
Это мой xml
<Book>
<Book>
<startDate>2005-02-14T00:00:00.000</startDate>
<endDate>2015-01-31T00:00:00.000</endDate>
<record>
<location>XXX</location>
<telephone>0891234</telephone>
<category>
<name>ABC</name>
<startdate>2005-02-14</startdate>
<endDate>2015-01-31</endDate>
</category>
<category>
<name>XYZ</name>
<startdate>2015-02-01</startdate>
<endDate>9999-12-31</endDate>
</category>
</record>
<Author>Manu</Author>
</Book>
<Book>
<startDate>2005-02-01T00:00:00.000</startDate>
<endDate>9999-12-31T00:00:00.000</endDate>
<record>
<location>XXX</location>
<telephone>0891234</telephone>
<category>
<name>ABC</name>
<startdate>2005-02-14</startdate>
<endDate>2015-01-31</endDate>
</category>
<category>
<name>XYZ</name>
<startdate>2005-02-01</startdate>
<endDate>9999-12-31</endDate>
</category>
</record>
<Author>Liverpool</Author>
</Book>
</Book>
Я хочу выбрать category
Узел, что \\category\startDate
равно \\book\startDate
и \\category\endDate
равны \\book\endDate
(игнорируйте метку времени на \\book\startDate
и \\book\endDate
только год, месяц и день компании)
Это ожидаемый результат
<Book>
<Book>
<startDate>2005-02-14T00:00:00.000</startDate>
<endDate>2015-01-31T00:00:00.000</endDate>
<record>
<location>XXX</location>
<telephone>0891234</telephone>
<category>
<name>ABC</name>
<startDate>2005-02-14</startDate>
<endDate>2015-01-31</endDate>
</category>
</record>
<Author>Manu</Author>
</Book>
<Book>
<startDate>2005-02-01T00:00:00.000</startDate>
<endDate>9999-12-31T00:00:00.000</endDate>
<record>
<location>XXX</location>
<telephone>0891234</telephone>
<category>
<name>XYZ</name>
<startDate>2005-02-01</startDate>
<endDate>9999-12-31</endDate>
</category>
</record>
<Author>Liverpool</Author>
</Book>
</Book>
Как я должен сделать? Это мой код.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="category">
<xsl:if test="//category/startDate = //Book/startDate and //category/endDate = //Book/endDate">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>