[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Predicates question
A basic requirement for writing XML (and XSLT is XML) is to represent all '<' that are part of the data (element or attribute or other) as < Another characters in the same category is '&', which must be written as &. when it is a data character (and not part of a character reference that begins with '&'). (You may also find '>' written as >.) There's also a construct known as CDATA section, which is a general "escape" mechanism for element data. See /bookstore/book[2] for details ;-) -W On 17 December 2011 14:39, Roelof Wobben <rwobben@xxxxxxxxxxx> wrote: > > > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|