my select statement only works on first listed of repeatable element

C

celerystick

This is an xsl question, comp.infosystems.www.authoring.stylesheets
were not able to help , here goes ....

With one xml file containing repeated element <subject>:

....<subject>Accounting</subject>
<subject>Business</subject>..

I can apply one stylesheet "Accountingfilter.xsl" that does this :

<xsl:for-each select="databases/database[subject='Accounting']"

And get output for all records where 'accounting' is listed in subject
elements

But I want to *also* apply, for another context, a second stylesheet
"businessfilter.xsl" that does

<xsl:for-each select="databases/database[subject='Business']"

Whenever I dont have <subject>business</subject> listed first in order
it does not work ....
..... unless I
switch the order in the xml to :

<subject>Business</subject>
<subject>Accounting </subject></database>

... then in this case the Accountingfilter.xsl sheet wont work as
intended.

How can I do this to get both to work regardless of the order of the
repeated element
<subject> ??

Thanks !!
 
R

Richard Tobin

celerystick said:
<xsl:for-each select="databases/database[subject='Business']"

Whenever I dont have <subject>business</subject> listed first in order
it does not work ....

This shouldn't happen, so you probably have some other mistake. You need
to post a complete (preferably small!) example that we can try.

-- Richard
 
C

celerystick

Thanks Richard and all, here is my master.xml and then
accountingfilter.xsl and businessfilter.xsl - these xsl files are
identifal except for 'Business' substituted for 'Accounting'

******master.xml***********************************
<?xml version="1.0" encoding="ISO8859-1"?>


<databases>
<database>
<name>ABI Inform Global</name>
<url>http://www.proquest.com/pqdauto?COPT=U0ZEPTlmU01EPTYmSU5UPTAmREJTPTM@</url>
<fulltext>Some Full Text</fulltext>
<description>International business periodicals covering management,
marketing, advertising, economics, human resources and more (dates
vary, with a few journals back to the 1960's).</description>

<subject>Accounting</subject>
<Business>Business</Business>
<class>A</class>
<ezproxyurl></ezproxyurl>
<encNo>137</encNo>
</database>



<database>
<name>Academic Search Premier</name>
<url>http://tinyurl.com/2x5qm</url>
<text>Some Full Text</text>
<description>General interest &amp; scholarly articles on a variety of
topics (dates vary, some journals back to 1975 or
earlier)</description>
<class>A</class><ezproxyurl></ezproxyurl>
<encNo></encNo>
<subject>Business</subject>
<subject>Accounting</subject>
<subject>General</subject>
</database>

****Accountingfilter.xsl***************
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="1" width="100%" bgcolor="F5F5F5">
<tr><xsl:element name = "a"><xsl:attribute name = "href">
</xsl:attribute>
<!--NAME of DATABASE APPEARS AS HYPERLINK --> <xsl:value-of
select="name"/>
</xsl:element>
<th>Database</th>
<th>Description</th>
</tr>
<xsl:for-each select="databases/database[subject='Accounting']">
<tr>

<td> <xsl:element name = "a"><xsl:attribute name =
"href"><xsl:value-of select="ezproxyurl"/><xsl:value-of select="url"/>
</xsl:attribute>
<!--NAME of DATABASE APPEARS AS HYPERLINK --> <xsl:value-of
select="name"/>
</xsl:element> </td>
<td><xsl:value-of select="description"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

*****businessfilter.xsl *******
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="1" width="100%" bgcolor="F5F5F5">
<tr><xsl:element name = "a"><xsl:attribute name = "href">
</xsl:attribute>
<!--NAME of DATABASE APPEARS AS HYPERLINK --> <xsl:value-of
select="name"/>
</xsl:element>
<th>Database</th>
<th>Description</th>
</tr>
<xsl:for-each select="databases/database[subject='Business']">
<tr>

<td> <xsl:element name = "a"><xsl:attribute name =
"href"><xsl:value-of select="ezproxyurl"/><xsl:value-of select="url"/>
</xsl:attribute>
<!--NAME of DATABASE APPEARS AS HYPERLINK --> <xsl:value-of
select="name"/>
</xsl:element> </td>
<td><xsl:value-of select="description"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
C

celerystick

David
I replaced the old namespace with an up to date one. It looks to be
working the way I need it now. Thanks very much to all of you. This
list is a great resource.
peace,
Charles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top