Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 09:41 AM
celerystick
Guest
 
Posts: n/a
Default 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 !!

  #2  
Old July 20th, 2005, 09:41 AM
Richard Tobin
Guest
 
Posts: n/a
Default Re: my select statement only works on first listed of repeatable element

In article <1117497175.587575.84760@g49g2000cwa.googlegroups. com>,
celerystick <emailchas@gmail.com> wrote:
[color=blue]
> <xsl:for-each select="databases/database[subject='Business']"
>
>Whenever I dont have <subject>business</subject> listed first in order
>it does not work ....[/color]

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
  #3  
Old July 20th, 2005, 09:41 AM
celerystick
Guest
 
Posts: n/a
Default Re: my select statement only works on first listed of repeatable element

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>

  #4  
Old July 20th, 2005, 09:41 AM
David Carlisle
Guest
 
Posts: n/a
Default Re: my select statement only works on first listed of repeatable element


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
  #5  
Old July 20th, 2005, 09:41 AM
celerystick
Guest
 
Posts: n/a
Default Re: my select statement only works on first listed of repeatable element

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:[color=blue]
> 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[/color]

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles