Libxml 1.0 Issue 5 #289

Closed
opened 2024-06-04 16:13:17 +02:00 by binkowsp · 2 comments

No error, no output

XSLT

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:a="http://www.demo.com/author"
                xmlns:b="http://www.demo.com"
                xmlns:p="http://www.demo.com/person"
                exclude-result-prefixes="xsl a p b xs"
>
    <xsl:template match="/">
        <xsl:variable name="authorAges">
            <xsl:variable name="books" select="document('xml2.xml')"/>
            <xsl:variable name="sortedBooks">
                <xsl:for-each select="$books/b:books/b:book">
                    <xsl:sort select="b:date"/>
                    <book>
                        <date><xsl:value-of select="xs:date(b:date)"/></date>
                        <authorId><xsl:value-of select="b:authorId"/></authorId>
                    </book>
                </xsl:for-each>
            </xsl:variable>
            <xsl:for-each select="a:authors/a:author">
                    <xsl:variable name="aId"><id><xsl:value-of select="@id"/></id></xsl:variable>
                    <xsl:variable name="bookDate" select="$sortedBooks/book[authorId=$aId/id]/date"/>
                    <xsl:variable name="authorDate" select="./a:dateOfBirth/text()"/>
                <duration>
                    <xsl:value-of select="24*days-from-duration(xs:date($sortedBooks/book[authorId=$aId/id][1]/date)-xs:date($authorDate))"/>
                </duration>
            </xsl:for-each>
        </xsl:variable>
        <xsl:variable name="avgDays" select="xs:int(avg($authorAges/*) div 24)"></xsl:variable>
        <xsl:variable name="avgHours" select="xs:int(avg($authorAges/*) mod 24)"></xsl:variable>
        <average_age>P<xsl:value-of select="$avgDays"/>DT<xsl:value-of select="$avgHours"/>H</average_age>
    </xsl:template>
</xsl:stylesheet>

XML1

<?xml version="1.0" encoding="UTF-8"?>
<a:authors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://www.demo.com/author"
           xmlns:a="http://www.demo.com/author"
           xmlns:p="http://www.demo.com/person"
           xsi:schemaLocation="http://www.demo.com/author author.xsd">
    <a:author id="1">
        <p:firstName>William</p:firstName>
        <p:lastName>Shakespeare</p:lastName>
        <a:dateOfBirth>1564-04-23</a:dateOfBirth>
        <a:dateOfDeath>1616-04-23</a:dateOfDeath>
    </a:author>
    <a:author id="2">
        <p:firstName>J.K.</p:firstName>
        <p:lastName>Rowling</p:lastName>
        <a:dateOfBirth>1965-07-31</a:dateOfBirth>
    </a:author>
    <a:author id="3">
        <p:firstName>Paulo</p:firstName>
        <p:lastName>Coelho</p:lastName>
        <a:dateOfBirth>1947-08-24</a:dateOfBirth>
    </a:author>
    <a:author id="4">
        <p:firstName>Stephen</p:firstName>
        <p:lastName>King</p:lastName>
        <a:dateOfBirth>1947-09-21</a:dateOfBirth>
    </a:author>
    <a:author id="5">
        <p:firstName>Tom</p:firstName>
        <p:lastName>Clancy</p:lastName>
        <a:dateOfBirth>1947-04-12</a:dateOfBirth>
        <a:dateOfDeath>2013-10-01</a:dateOfDeath>
    </a:author>
    <a:author id="6">
        <p:firstName>Napoleon</p:firstName>
        <p:lastName>Hill</p:lastName>
        <a:dateOfBirth>1883-09-26</a:dateOfBirth>
        <a:dateOfDeath>1970-11-08</a:dateOfDeath>
    </a:author>
</a:authors>

XML2

<?xml version="1.0" encoding="utf-8"?>
<b:books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://www.demo.com"
         xmlns:b="http://www.demo.com"
         xsi:schemaLocation="http://www.demo.com book.xsd">
    <b:book id="1">
        <name>Hamlet</name>
        <date>2001-05-04</date>
        <authorId>1</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="2">
        <name>Macbeth</name>
        <date>2000-12-13</date>
        <authorId>1</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="3">
        <name>Harry Potter and the Sorcerer's Stone</name>
        <date>2005-04-29</date>
        <authorId>2</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="4">
        <name>The Long Walk</name>
        <date>2018-07-01</date>
        <authorId>4</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="5">
        <name>Misery</name>
        <date>2018-01-31</date>
        <authorId>4</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="6">
        <name>Think and Grow Rich</name>
        <date>2004-09-10</date>
        <authorId>6</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="7">
        <name>The Law of Success</name>
        <date>1982-05-09</date>
        <authorId>6</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="8">
        <name>Patriot Games</name>
        <date>1995-10-21</date>
        <authorId>5</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="9">
        <name>The Sum of All Fears</name>
        <date>1992-09-19</date>
        <authorId>5</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="10">
        <name>The Alchemist</name>
        <date>2017-02-20</date>
        <authorId>3</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="11">
        <name>Hamlet</name>
        <date>1994-06-01</date>
        <authorId>1</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="12">
        <name>Measure for Measure</name>
        <date>1990-03-23</date>
        <authorId>1</authorId>
        <availability>false</availability>
    </b:book>
    <b:book id="13">
        <name>Hamlet</name>
        <date>1989-05-05</date>
        <authorId>1</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="14">
        <name>Hamlet</name>
        <date>1999-05-30</date>
        <authorId>1</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="15">
        <name>The Law of Success</name>
        <date>2004-11-26</date>
        <authorId>6</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="16">
        <name>Romeo and Juliet</name>
        <date>1997-02-08</date>
        <authorId>1</authorId>
        <availability>true</availability>
    </b:book>
    <b:book id="17">
        <name>The Alchemist</name>
        <date>2009-08-21</date>
        <authorId>3</authorId>
        <availability>true</availability>
    </b:book>
</b:books>

No error, no output XSLT ``` <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:a="http://www.demo.com/author" xmlns:b="http://www.demo.com" xmlns:p="http://www.demo.com/person" exclude-result-prefixes="xsl a p b xs" > <xsl:template match="/"> <xsl:variable name="authorAges"> <xsl:variable name="books" select="document('xml2.xml')"/> <xsl:variable name="sortedBooks"> <xsl:for-each select="$books/b:books/b:book"> <xsl:sort select="b:date"/> <book> <date><xsl:value-of select="xs:date(b:date)"/></date> <authorId><xsl:value-of select="b:authorId"/></authorId> </book> </xsl:for-each> </xsl:variable> <xsl:for-each select="a:authors/a:author"> <xsl:variable name="aId"><id><xsl:value-of select="@id"/></id></xsl:variable> <xsl:variable name="bookDate" select="$sortedBooks/book[authorId=$aId/id]/date"/> <xsl:variable name="authorDate" select="./a:dateOfBirth/text()"/> <duration> <xsl:value-of select="24*days-from-duration(xs:date($sortedBooks/book[authorId=$aId/id][1]/date)-xs:date($authorDate))"/> </duration> </xsl:for-each> </xsl:variable> <xsl:variable name="avgDays" select="xs:int(avg($authorAges/*) div 24)"></xsl:variable> <xsl:variable name="avgHours" select="xs:int(avg($authorAges/*) mod 24)"></xsl:variable> <average_age>P<xsl:value-of select="$avgDays"/>DT<xsl:value-of select="$avgHours"/>H</average_age> </xsl:template> </xsl:stylesheet> ``` XML1 ``` <?xml version="1.0" encoding="UTF-8"?> <a:authors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.demo.com/author" xmlns:a="http://www.demo.com/author" xmlns:p="http://www.demo.com/person" xsi:schemaLocation="http://www.demo.com/author author.xsd"> <a:author id="1"> <p:firstName>William</p:firstName> <p:lastName>Shakespeare</p:lastName> <a:dateOfBirth>1564-04-23</a:dateOfBirth> <a:dateOfDeath>1616-04-23</a:dateOfDeath> </a:author> <a:author id="2"> <p:firstName>J.K.</p:firstName> <p:lastName>Rowling</p:lastName> <a:dateOfBirth>1965-07-31</a:dateOfBirth> </a:author> <a:author id="3"> <p:firstName>Paulo</p:firstName> <p:lastName>Coelho</p:lastName> <a:dateOfBirth>1947-08-24</a:dateOfBirth> </a:author> <a:author id="4"> <p:firstName>Stephen</p:firstName> <p:lastName>King</p:lastName> <a:dateOfBirth>1947-09-21</a:dateOfBirth> </a:author> <a:author id="5"> <p:firstName>Tom</p:firstName> <p:lastName>Clancy</p:lastName> <a:dateOfBirth>1947-04-12</a:dateOfBirth> <a:dateOfDeath>2013-10-01</a:dateOfDeath> </a:author> <a:author id="6"> <p:firstName>Napoleon</p:firstName> <p:lastName>Hill</p:lastName> <a:dateOfBirth>1883-09-26</a:dateOfBirth> <a:dateOfDeath>1970-11-08</a:dateOfDeath> </a:author> </a:authors> ``` XML2 ``` <?xml version="1.0" encoding="utf-8"?> <b:books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.demo.com" xmlns:b="http://www.demo.com" xsi:schemaLocation="http://www.demo.com book.xsd"> <b:book id="1"> <name>Hamlet</name> <date>2001-05-04</date> <authorId>1</authorId> <availability>false</availability> </b:book> <b:book id="2"> <name>Macbeth</name> <date>2000-12-13</date> <authorId>1</authorId> <availability>false</availability> </b:book> <b:book id="3"> <name>Harry Potter and the Sorcerer's Stone</name> <date>2005-04-29</date> <authorId>2</authorId> <availability>true</availability> </b:book> <b:book id="4"> <name>The Long Walk</name> <date>2018-07-01</date> <authorId>4</authorId> <availability>true</availability> </b:book> <b:book id="5"> <name>Misery</name> <date>2018-01-31</date> <authorId>4</authorId> <availability>true</availability> </b:book> <b:book id="6"> <name>Think and Grow Rich</name> <date>2004-09-10</date> <authorId>6</authorId> <availability>true</availability> </b:book> <b:book id="7"> <name>The Law of Success</name> <date>1982-05-09</date> <authorId>6</authorId> <availability>false</availability> </b:book> <b:book id="8"> <name>Patriot Games</name> <date>1995-10-21</date> <authorId>5</authorId> <availability>false</availability> </b:book> <b:book id="9"> <name>The Sum of All Fears</name> <date>1992-09-19</date> <authorId>5</authorId> <availability>false</availability> </b:book> <b:book id="10"> <name>The Alchemist</name> <date>2017-02-20</date> <authorId>3</authorId> <availability>false</availability> </b:book> <b:book id="11"> <name>Hamlet</name> <date>1994-06-01</date> <authorId>1</authorId> <availability>false</availability> </b:book> <b:book id="12"> <name>Measure for Measure</name> <date>1990-03-23</date> <authorId>1</authorId> <availability>false</availability> </b:book> <b:book id="13"> <name>Hamlet</name> <date>1989-05-05</date> <authorId>1</authorId> <availability>true</availability> </b:book> <b:book id="14"> <name>Hamlet</name> <date>1999-05-30</date> <authorId>1</authorId> <availability>true</availability> </b:book> <b:book id="15"> <name>The Law of Success</name> <date>2004-11-26</date> <authorId>6</authorId> <availability>true</availability> </b:book> <b:book id="16"> <name>Romeo and Juliet</name> <date>1997-02-08</date> <authorId>1</authorId> <availability>true</availability> </b:book> <b:book id="17"> <name>The Alchemist</name> <date>2009-08-21</date> <authorId>3</authorId> <availability>true</availability> </b:book> </b:books> ```
Author

Chyba odkryłem czemu w tym i poprzednich przypadkach libxml nie działa. Jeżeli w toolsach mamy odpalony więcej niż 1 plik xmlowy to występuje ten problem. Jeżeli jest tylko 1 plik to libxml działa.

Chyba odkryłem czemu w tym i poprzednich przypadkach libxml nie działa. Jeżeli w toolsach mamy odpalony więcej niż 1 plik xmlowy to występuje ten problem. Jeżeli jest tylko 1 plik to libxml działa.
Collaborator

fixed in #297

fixed in #297
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: R11/release11-tools#289
No description provided.