[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How would you like a new axis? time::

Subject: Re: How would you like a new axis? time::
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Sun, 14 Mar 2010 20:37:49 +0530
Re:  How would you like a new axis? time::
Hi Mike,

On Sun, Mar 14, 2010 at 7:04 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> So how would you find a product element whose price today is less than its
> price a week ago?

I might, like to keep a sequence of "price" nodes for a product,
instead of only one price for a product. Each price information can
have an "effective" date.

Therefore, I might have a schema like following:
<xs:complexType name="Product">
  <xs:sequence>
    <xs:element name="name" type="xs:string" />
    <xs:element name="price" maxOccurs="unbounded">
      <xs:simpleType>
        <xs:extension base="xs:double">
          <xs:attribute name="effective" type="xs:dateTime" />
        </xs:extension>
      </xs:simpleType>
    </xs:element>
  </xs:sequence>
  <xs:attribute name="ID" type="xs:string" />
</xs:complexType>

<xs:element name="product" type="Product" maxOccurs="unbounded" />

If the corresponding XML instance is like following:
<product ID="100">
  <name>kitchen sink</name>
  <price effective="2010-03-07">15</price>
  <price effective="2010-03-14">10</price>
</product>

I can get the products as you suggested, as follows:
//product[price[last()] lt price[last() - 1]]

This technique, doesn't use the creation & modification dateTime's as
I suggested initially, but this uses a custom schema.


-- 
Regards,
Mukul Gandhi

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.