• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

xsl issue for newbie

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I'm trying to render certain data into the browser. In particular:
1. To render all products in stock (which include those already available and will be available 2 days after placing the order) - displaying full product dtls (all elements)
2. To render all products having a delivery charge of less than 3 dollars.
Here's my xml:

Here's my attempt at no.1:

I know the syntax is wrong for the if statement - how should it be done?
And no.2 attempt:

At the moment for the above xsl file, I dont get any results displayed. Where am I going wrong?
At the moment I have to change the file name in the xml doc to select the relevant xsl document - but is there a smart way to be able to create a singe xml document that links to multiple xsl files?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some quick tips:
1) You need to encode the "<" and ">" within your if statements as "&lt;" and "&gt;"
2) You're referring to "InStock" and "LeadTime" when you should be referring to "Stock/InStock" and "Stock/LeadTime"
3) You've got a typo in "Product/Product"
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
4) If the LeadTime elements have values like "3 working days", you can't do a numeric comparison with "<" etc. Instead, you need to use a string function like substring-before(Stock/LeadTime, ' '), which strips away everything except the number you want to compare with something.
There's a decent XPath/XSL function reference at w3schools.com
 
Rob Patterson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lasse,
I used a 'when' instead of the 'if; fixed the typos and it seems to work now. Just got to find a decent parser to use now.
Thanks for your help.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
ScroogeXHTML - fast RTF to HTML and XHTML conversion
https://coderanch.com/t/749563/ScroogeXHTML-fast-RTF-HTML-XHTML
reply
    Bookmark Topic Watch Topic
  • New Topic