XSLT IF Multiple Conditions
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Mon May 11, 2015 5:19 pm
XSLT IF Multiple Conditions
Post by lukeharris95 »
Hi,
I have created a CV as my XML document. I have than made a XSL which produces either a accept/reject letter based on if certain words appear in the XML.
That criteria is as follows: If the word 'Web Developer' appear in <experienceSummary> AND 'Information' OR 'Computer' OR 'Web' appear in <educationSummary> then load up a accept letter. If this criteria is not met load up a reject letter.
I have got it working for the word 'Web Developer' but I'm not sure how to connect the other words to this expression.
I have searched almost everywhere for a solution with no luck!! Surely it can't be that hard to have a IF test with multiple conditions. Thanks in advance for any help given, will be much appreciated!
I have created a CV as my XML document. I have than made a XSL which produces either a accept/reject letter based on if certain words appear in the XML.
That criteria is as follows: If the word 'Web Developer' appear in <experienceSummary> AND 'Information' OR 'Computer' OR 'Web' appear in <educationSummary> then load up a accept letter. If this criteria is not met load up a reject letter.
I have got it working for the word 'Web Developer' but I'm not sure how to connect the other words to this expression.
Code: Select all
<xsl:variable name="search">
<xsl:value-of select="//experienceSummary"/>
</xsl:variable>
<xsl:variable name="expSearch">
<xsl:value-of select="//educationSummary"/>
</xsl:variable>
<xsl:if test="contains($search, 'Web Developer')">
<!-- <xsl:if test="contains($search, 'Web Developer' and ($expSearch='Computer' or $expSearch='Information' or $expSearch='Web' ))"> -->
<!-- <xsl:if test="contains($search, 'Web Developer' and (contains($expSearch, 'Computer' or 'Information' or 'Web' )))"> -->
<p>Buckinghamshire New University regard that your experience as a Web Developer to be relevant to this post.</p>
<p>Your award [item title from CV XML], also fulfils elements of the job description.</p>
<p>We are therefore pleased to invite to an interview on: Monday 18th May 2015.</p>
</xsl:if>
<xsl:if test="not(contains($search, 'Web Developer'))">
<p>Buckinghamshire New University received many applications for this post. Due to the strength of the field we regret that you have not been selected for an interview on this occasion.</p>
<p>We will, however, keep your CV on file for consideration when similar opportunities arise.</p>
</xsl:if>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XSLT IF Multiple Conditions
Hi,
If you use boolean operators (or/and) between strings, you'll get a boolean result (true/false), which isn't useful since you need a string for the contains() function. So you need to apply contains() on each individual string.
Regards,
Adrian
If you use boolean operators (or/and) between strings, you'll get a boolean result (true/false), which isn't useful since you need a string for the contains() function. So you need to apply contains() on each individual string.
Code: Select all
<xsl:if test="contains($search, 'Web Developer') and (contains($expSearch, 'Computer') or contains($expSearch, 'Information') or contains($expSearch, 'Web' ))">
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Mon May 11, 2015 5:19 pm
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service