This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Complex expression problem...
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: Complex expression problem...
- From: Jonathan Asbell <jonathana at raremedium dot com>
- Date: Mon, 27 Mar 2000 14:13:03 -0500
- Reply-To: xsl-list at mulberrytech dot com
Your code below is not working. I think the problem is in my syntax. I
need to express:
XSL FILE EXCERPT-----------------------------------------------
<xsl:template name="recordchooser">
<xsl:variable name="path" select="/customers/customer"/>
<xsl:param name="_id" select="'RICAR'"/>
<xsl:param name="_company" select="'Ricardo'"/>
<xsl:param name="_contact" select="'Janete Limeira'"/>
<xsl:param name="_title" select="'Assistant'"/>
<xsl:param name="_address" select="'Copacabana'"/>
<xsl:param name="_city" select="'Rio de Janeiro'"/>
<xsl:param name="_region" select="'RJ'"/>
<xsl:param name="_postal" select="'02389-890'"/>
<xsl:param name="_country" select="'Brazil'"/>
<xsl:param name="_phone" select="'555-3412'"/>
<xsl:param name="_fax" select="'555-3413'"/>
<xsl:for-each select="
$path/customer_id[contains(.,{$_id})] and
$path/company_name[contains(company_name,{$_company})] and
$path/contact_name[contains(.,{$_contact})] and
$path/contact_title[contains(.,{$_title})] and
$path/address[contains(.,{$_address})] and
$path/city[contains(.,{$_city})] and
$path/region[contains(.,{$_region})] and
$path/postal_code[contains(.,{$_postal})] and
$path/country[contains(.,{$_country})] and
$path/phone[contains(.,{$_phone})] and
$path/fax[contains(.,{$_fax})]
">
</xsl:template>
XML FILE EXCERPT---------------------------------------------------
<customers>
<customer>
<customer_id>ALFKI</customer_id>
<company_name>Alfreds Futterkiste</company_name>
<contact_name>Maria Anders</contact_name>
<contact_title>Sales Representative</contact_title>
<address>Obere Str. 57</address>
<city>Berlin</city>
<region></region>
<postal_code>12209</postal_code>
<country>Germany</country>
<phone>030-0074321</phone>
<fax>030-0076545</fax>
</customer>
etc...
etc...
</customers>
I want to display all matching records
-----Original Message-----
From: Steve Muench [mailto:smuench@us.oracle.com]
Sent: Friday, March 24, 2000 7:03 PM
To: xsl-list@mulberrytech.com
Subject: Re: Complex expression problem...
and cannot connect nodesets are you're trying to do here.
You likely intend something like this:
<out xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
<xsl:variable name="_id">AROUT</xsl:variable>
<xsl:variable name="_company">Horn</xsl:variable>
<xsl:for-each select="/customers/customer[
contains(customer_id ,$_id )
and contains(company_name,$_company)
]">
<contact><xsl:value-of select="contact_name"/></contact>
</xsl:for-each>
</out>
Where the "and" is connecting boolean contains() expressions.
______________________________________________________________
Steve Muench, Lead XML Evangelist & Consulting Product Manager
Business Components for Java Dev't Team, Oracle Corporation
----- Original Message -----
From: "Jonathan Asbell" <jonathana@raremedium.com>
To: <xsl-list@mulberrytech.com>
Sent: Friday, March 24, 2000 3:23 PM
Subject: RE: Complex expression problem...
| My code is below and the parser says the result can not be converted to a
| node set
|
| <xsl:variable name="path" select="/customers/customer"/>
| <xsl:for-each select="
| $path/customer_id[contains(.,$_id)]
| and
| $path/company_name[contains(.,$_company)]
| and
| $path/contact_name[contains(.,$_contact)]
| and
| $path/contact_title[contains(.,$_title)]
| and
| $path/address[contains(.,$_address)]
| and
| $path/city[contains(.,$_city)]
| and
| $path/region[contains(.,$_region)]
| and
| $path/postal_code[contains(.,$_postal)]
| and
| $path/country[contains(.,$_country)]
| and
| $path/phone[contains(.,$_phone)]
| and
| $path/fax[contains(.,$_fax)]
| ">
|
| -----Original Message-----
| From: Steve Muench [mailto:smuench@us.oracle.com]
| Sent: Friday, March 24, 2000 5:27 PM
| To: xsl-list@mulberrytech.com
| Subject: Re: Complex expression problem...
|
|
| <xsl:for-each
| select="/customers/customer[starts-with(name,'a')
| and
| starts-with(city,'b')
| and
| starts-with(zip,'9')]">
| :
| :
| </xsl:for-each>
|
| Although, if you'll be doing this over thousands of
| customers *AND* you are already pulling the customer
| information from a database, you might want to
| push this query through and let your database filter
| the rows *before* rendering the resulting matches
| as XML to make things go a lot faster...Just a thought,
| and might not apply to your situation, but seemed
| like it was worth suggesting...
|
| ______________________________________________________________
| Steve Muench, Lead XML Evangelist & Consulting Product Manager
| Business Components for Java Dev't Team, Oracle Corporation
|
| ----- Original Message -----
| From: "Jonathan Asbell" <jonathana@raremedium.com>
| To: <xsl-list@mulberrytech.com>
| Sent: Friday, March 24, 2000 2:12 PM
| Subject: Complex expression problem...
|
|
| | How do I say
| |
| | __________________________________
| | for each customer where....
| | the value of "name" begins with "a"
| | and
| | the value of "city" begins with "p"
| | and
| | the value of "zip" begins with "9"
| | output their field values
| | (that is for each one that matches the criteria, give me their records)
| | __________________________________
| |
| |
| | the xml is below.....
| |
| |
| | <customers>
| | <customer>
| | <customer_id>ALFKI</customer_id>
| | <company_name>Alfreds Futterkiste</company_name>
| | <contact_name>Maria Anders</contact_name>
| | <contact_title>Sales Representative</contact_title>
| | <address>Obere Str. 57</address>
| | <city>Berlin</city>
| | <region></region>
| | <postal_code>12209</postal_code>
| | <country>Germany</country>
| | <phone>030-0074321</phone>
| | <fax>030-0076545</fax>
| | </customer>
| | <customer>
| | <customer_id>AROUT</customer_id>
| | <company_name>Around the Horn</company_name>
| | <contact_name>Thomas Hardy</contact_name>
| | <contact_title>Sales Representative</contact_title>
| | <address>120 Hanover Sq.</address>
| | <city>London</city>
| | <region></region>
| | <postal_code>WA1 1DP</postal_code>
| | <country>UK</country>
| | <phone>(171) 555-7788</phone>
| | <fax>(171) 555-6750</fax>
| | </customer>
| |
| | etc.......
| |
| | </customers>
| |
| |
| | XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| |
|
|
| XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
|
| XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list