Note that there are some explanatory texts on larger screens.

plurals
  1. POxpath for counting childnodes with the same tag name
    primarykey
    data
    text
    <p>i need to find all the book and if the book has more than one author,write the first authors name and "et al" after that name.Below is my code and first book prints with "J.K. Rowling et al" but its not working for the second book.</p> <p>this is the xml code</p> <pre><code> &lt;bookstore&gt; &lt;book&gt; &lt;title category="fiction"&gt;Harry Potter&lt;/title&gt; &lt;author&gt;J. K. Rowling&lt;/author&gt; &lt;author&gt;sxdgfds&lt;/author&gt; &lt;publisher&gt;Bloomsbury&lt;/publisher&gt; &lt;year&gt;2005&lt;/year&gt; &lt;price&gt;29.99&lt;/price&gt; &lt;/book&gt; &lt;book&gt; &lt;title category="fiction"&gt;The Vampire Diaries&lt;/title&gt; &lt;author&gt;L.J. Smith&lt;/author&gt; &lt;author&gt;sdgsdgsdgdsg&lt;/author&gt; &lt;publisher&gt;Bloomsbury&lt;/publisher&gt; &lt;year&gt;2004&lt;/year&gt; &lt;price&gt;25.99&lt;/price&gt; &lt;/book&gt; &lt;book&gt; &lt;title category="fiction"&gt;The DaVinci Code&lt;/title&gt; &lt;author&gt;Dan Brown&lt;/author&gt; &lt;publisher&gt;Bloomsbury&lt;/publisher&gt; &lt;year&gt;2002&lt;/year&gt; &lt;price&gt;35.99&lt;/price&gt; &lt;/book&gt; </code></pre> <p>this is the xslt code</p> <pre><code> &lt;xsl:for-each select="//book[30 &gt;price]"&gt; &lt;xsl:if test="title[@category='fiction']"&gt; &lt;span style="color:blue;font-weight:bold"&gt;&lt;xsl:value-of select="title"/&gt;&lt;/span&gt;&lt;br /&gt; &lt;xsl:choose&gt; &lt;xsl:when test="count(./author)&gt;1"&gt; &lt;span style="color:red;font-style:italic"&gt;&lt;xsl:value-of select="author"/&gt;&lt;/span&gt; &lt;span style="color:red;font-style:italic"&gt; et al&lt;/span&gt;&lt;br /&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;span style="color:red;font-style:italic"&gt;&lt;xsl:value-of select="author"/&gt;&lt;/span&gt;&lt;br /&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;span&gt;&lt;xsl:value-of select="price"/&gt;&lt;/span&gt;&lt;br /&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; </code></pre> <p>i was trying to count how many authors are there but seems like i'm having a problem with the path that i have given to the count function.Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload