XSLTGeneral 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
add 5 years to date in three nodes in xml document
Hi
I am trying to add 5 years to three nodes but it takes the first node date and it applies it to the following two nodes. Help would be appreciated.
Here is my xslt.
Your variable $maturDate1 is a node-set containing 5 element nodes.
In XSLT 1.0, when you apply the substring() function to a set of 5 nodes, it operates on the first of those nodes (2.0 would give you a type error instead).
Note, your date arithmetic is capable of generating an invalid date like 20090229. Using the date/time arithmetic provided in XSLT 2.0 would be more sound.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
I have to use xslt 1.0. and my real problem that I need to update every date independently in the node-set, I have tried what you suggested to match on the maturity date. I still get the node-set and can not correctly update teh dates in each node. is there away to preserve the xml structure and add 5 years to each date in the node.
I made the global variable a local variable in the template as you suggested.
>I made the global variable a local variable in the template as you suggested.
I suggested nothing of the kind. It looks as if you didn't understand my code and changed it. Please show me the code you have now written and that still isn't working. Then perhaps I can see where your mental block is. Unfortunately writing code for people is often not a good way to solve their misunderstandings of the language.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post: