Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2015, 09:42 AM
Registered User
 
Join Date: Aug 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compare dates in multiple nodes

XML:
Code:
<ProductRevision id="id38" name="Item1" accessRefs="#id4" subType="ItemRev" masterRef="#id36" revision="A">
  <UserData id="id39">
    <UserValue value="2015-08-11T16:46:20" title="date_released"></UserValue>
  </UserData>  
</ProductRevision>

<ProductRevision id="id53" name="Item2" accessRefs="#id4" subType="ItemRev" masterRef="#id36" revision="A">
  <UserData id="id39">
    <UserValue value="2015-08-07T13:57:42" title="date_released"></UserValue>
  </UserData>  
</ProductRevision>

<ProductRevision id="id68" name="Item2" accessRefs="#id4" subType="ItemRev" masterRef="#id36" revision="A">
  <UserData id="id39">
    <UserValue value="2015-08-06T13:57:42" title="date_released"></UserValue>
  </UserData>  
</ProductRevision>

<Product id="id36" name="Item1" accessRefs="#id4" subType="Item" productId="1234">
  <ApplicationRef version="g7cVc2GTznicWC" application="Teamcenter" label="g7cVc2GTznicWC"></ApplicationRef>
  <AssociatedForm id="id50" role="IMAN_master_form" formRef="#id48"></AssociatedForm>
</Product>
<Product id="id51" name="Item2" accessRefs="#id4" subType="Item" productId="BXU004846">
  <ApplicationRef version="gLZVMV_wznicWC" application="Teamcenter" label="gLZVMV_wznicWC"></ApplicationRef>
  <AssociatedForm id="id65" role="IMAN_master_form" formRef="#id63"></AssociatedForm>
</Product>
<Product id="id66" name="Item3" accessRefs="#id4" subType="Item" productId="BXU004848">
  <ApplicationRef version="weVVMpxFznicWC" application="Teamcenter" label="weVVMpxFznicWC"></ApplicationRef>
  <AssociatedForm id="id80" role="IMAN_master_form" formRef="#id78"></AssociatedForm>
</Product>

<Form id="id48" name="1234" accessRefs="#id4" subType="Item Master" subClass="Item Master">  
  <UserData id="id49" type="FormAttributes">    
    <UserValue value="Class1" title="form_type"></UserValue>    
  </UserData>
</Form>
<Form id="id63" name="BXU004846" accessRefs="#id4" subType="Item Master" subClass="Item Master">  
  <UserData id="id64" type="FormAttributes">    
    <UserValue value="Class1" title="form_type"></UserValue>    
  </UserData>
</Form>
<Form id="id78" name="BXU004848" accessRefs="#id4" subType="Item Master" subClass="Item Master">  
  <UserData id="id79" type="FormAttributes">    
    <UserValue value="Class2" title="form_type"></UserValue>    
  </UserData>
</Form>
In the above xml, - ProductRevision node is related to Product Node through 'masterRef' value. 'masterRef' id on ProductRevision is equal to 'id' value on Product node. - Product node is related to Form node through 'formRef' value. 'formRef' id on Product/AssociatedForm/formRef is equal to 'id' value of Form node. In the above example i have to find the latest date_released of ProductRevision with form_type 'Class1' (form_type value is in Form node).

For example to find if first ProductRevision node is of type Class1: - Go to Product node (id36) and get its formRef id (id48) - product/AssociatedForm/formRef - Search Form xml nodes with id value as id48. In Form node, get form_type value and check if its 'Class1'. - If its Class1, to get date_released we have to go to corresponding ProductRevision node. - Search ProductRevision nodes with masterRef value as id36. Get date_released form ProductRevision node.

I was able to write logic to traverse the nodes and check form_type value and get date_released, but stuck on how to get latest date_released from these nodes. Requirement is to get latest date_released of ProductRevision's with form_type as 'Class1'.





Similar Threads
Thread Thread Starter Forum Replies Last Post
compare dates in xslt krishk189 XSLT 3 April 17th, 2014 10:34 AM
How to compare two dates lakshmi_annayappa Javascript 1 September 3rd, 2007 08:52 AM
How do I compare 2 dates? Lucy Classic ASP Basics 1 May 3rd, 2005 07:24 PM
Compare dates langer123 Classic ASP Basics 2 April 16th, 2005 08:57 AM
Compare Dates in JS apd8x Javascript 4 June 16th, 2003 08:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.