xsl-list
[Top] [All Lists]

[xsl] Predicates question

2011-12-17 07:39:30


I have this small xml file : 

 

<?xml version="1.0" encoding="ISO-8859-1"?>
 <bookstore>

 <book>
   <title lang="eng">Harry Potter</title>
   <price>29.99</price>
 </book>

 <book>
   <title lang="eng">Learning XML</title>
   <price>39.95</price>
 </book>

 </bookstore> 

 

And now I want to show only a few books.

According to this page : http://www.w3schools.com/xpath/xpath_syntax.asp I can 
use this xslt : 

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 
<xsl:template match="/">
   <xsl:apply-templates select="/bookstore/book[position()<3]" />
</xsl:template>

<xsl:template match="bookstore/book">
   <h1><xsl:value-of select="title"</h1>
   <xsl:value-of select="price"
</xsl:template>
  
</xsl:stylesheet>


But if I try this on xmlspy I get this message : 

 

Character '<' is grammatically unexpected
 Reason: one of the following is expected (see below)
  '"'
  '&'
  '&#'
  '&#x'
  [^<&"]
 Details
  XML production: Production 'AttValue' not satisfied

 

What part did I misunderstood. 

 

Roelof

                                          
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>