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(_at_)nag(_dot_)co(_dot_)uk> 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 :)
--~------------------------------------------------------------------
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>
--~--
.
--
Martin Holmes
University of Victoria Humanities Computing and Media Centre
(mholmes(_at_)uvic(_dot_)ca)
--~------------------------------------------------------------------
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>
--~--