[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Re: xhtml via xslt failure
Subject: Re: Re: xhtml via xslt failure
From: Martin Holmes <mholmes@xxxxxxx>
Date: Tue, 17 Dec 2013 11:02:10 -0800
|
Your template here matches "bookstore/book", but it seems to be written
as if it matches "author".
You might want to try changing the match to:
<xsl:template match="bookstore/book/author">
so that it applies only to instances of author which are children of
books. Assuming that's what you want. If you want to process the authors
that are siblings of books, of course, you want:
<xsl:template match="bookstore/author">
I think when you're getting started, it doesn't really help much to read
the specifications; I'd do some tutorials first. The specs are hard to
grasp unless you're already fairly comfortable with basic XSLT.
Hope this helps,
Martin
On 13-12-17 10:43 AM, e-letter wrote:
On 17/12/2013, David Carlisle <davidc@xxxxxxxxx> wrote:
On 17/12/2013 17:08, e-letter wrote:
Don't understand, seems nested:
It is nested (unless you cut and pasted the wrong thing)
You have one xsl:template element inside another. The stylesheet should
not compile, and you should get no output.
Compilation occurred, so this is probably due to the processing
environment (jedit). Anyway, the nested element was removed:
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns='http://www.w3.org/1999/xhtml'
>
<xsl:import href="xqueryexampledata.xml"/>
<xsl:output
method="xml"
doctype-public="-//W3C//DTD XHTML Basic 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"
encoding="utf-8"
indent="no"
omit-xml-declaration="yes"
media-type="text/xml"
standalone="yes"
version="1.1"
/>
<xsl:template
match='/'
>
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
<head>
<meta
name='notice' content='xhtml document created by xml transformation' />
<title>Test output web page</title>
</head>
<body>
<xsl:apply-templates
select='*'
/>
</body>
</html>
</xsl:template>
<xsl:template
match="bookstore/book"
>
<p>
<xsl:if
test="following-sibling::author">
and
</xsl:if>
<xsl:apply-templates
select='author'
/>
</p>
</xsl:template>
</xsl:stylesheet>
The transformation result:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"><head><meta content="xhtml document created by xml
transformation" name="notice" /><title>Test output web
page</title></head><body>
<p>Giada De Laurentiis</p>
<p>J K. Rowling</p>
<p>James McGovernPer BothnerKurt CagleJames LinnVaidyanathan Nagarajan</p>
<p>Erik T. Ray</p>
</body></html>
The xml file has authors in two positions to consider, single authors
as child elements of 'book' and as multiple sibling elements of the
parent 'book' (i.e. each author is a separate child element), so it
seems that the suggestion to use element attribute
'test="following-sibling::author"' is not applicable.
Back to reading the specifications :)
.
--
Martin Holmes
University of Victoria Humanities Computing and Media Centre
(mholmes@xxxxxxx)

|
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
RSS 2.0 |
|
Atom 0.3 |
|
|