473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

my select statement only works on first listed of repeatable element

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 !!

Jul 20 '05 #1
4 1482
In article <11*********************@g49g2000cwa.googlegroups. com>,
celerystick <em*******@gmail.com> wrote:
<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
Jul 20 '05 #2
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>

Jul 20 '05 #3

Don't use
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
that is a microsoft-only language implemented in msxml2 and supported but
deprecated in msxml3 and not supported at all in msxml4. It's almost
completely unrelated to xslt except that some elements have similar
names.

XSLT uses the namespace

http://www.w3.org/1999/XSL/Transform
msxml 3 and 4 both support XSLT.

David
Jul 20 '05 #4
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
David Carlisle wrote:
Don't use
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
that is a microsoft-only language implemented in msxml2 and supported but
deprecated in msxml3 and not supported at all in msxml4. It's almost
completely unrelated to xslt except that some elements have similar
names.

XSLT uses the namespace

http://www.w3.org/1999/XSL/Transform
msxml 3 and 4 both support XSLT.

David


Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael | last post by:
I have two tables with a 1-many relationship. I want to write a select statement that looks in the table w/many records and compares it to the records in the primary table to see if there are any...
1
by: Jurrie | last post by:
Hi all, I use apaches FOP to translate an XML-document into a PDF-document. I use repeatable-page-master-alternitives, but FOP gives some strange errors: Unsupported element encountered:...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
14
by: deko | last post by:
Can the DROP TABLE statement be used with a select or where statement? DROP TABLE SELECT * FROM tblTablesImported WHERE Import_ID Not In (SELECT FROM tblTablesInternal); Or do I have to...
26
by: GreatAlterEgo | last post by:
Hi, This is my query which is embedded in a COBOL program. EXEC SQL SELECT DATE, AGE, DURATION, AMT INTO :LDATE, :L.AGE, :L.DURATION, :L.AMT FROM TAB1 WHERE CODE = :KEY.CODE AND...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
14
by: lewindletter | last post by:
Hi If I do Begin transaction Stmt 1: select count(*) from tableA If the count is zero, then proceed to the following Stmt 2: insert "something" to tableA Stmt 3: insert "something" to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.