|
Rank: Newbie
Joined: 10/7/2020 Posts: 8 Location: Ukraine
|
Hello,
I'm completely new in Altova products. And my question is:
We have Altova StyleVision and using it to create PDFs from XML. In one field I need to use IF condition. So I use XPATH Expression (User-Defined-Template) with IF - THEN - ELSE IF - THEN - ELSE confition. If works fine if I use XSLT 2.0 button in the tool panel. But unfortunately our customer supports only XSLT 1.0. When I press XLST 1.0 button this structure fails - I assume because XSLT 1.0 does not support IF statement.
I realize that instead of IF I could use something like
<xsl:choose> <xsl:when test=... .................. </xsl:choose>.
But it also fails - I assume because I can use only XPATH, not pure XSLT.
So my question is: is it possible to use pure XSLT container somehow? What other workaround could be used?
Thanks a lot for any answer.
|
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 558
|
Why not simply use StyleVision's own condition functionality? That works using XSLT 1.0.
|
|
Rank: Newbie
Joined: 10/7/2020 Posts: 8 Location: Ukraine
|
K101 wrote:Why not simply use StyleVision's own condition functionality? That works using XSLT 1.0. Hello K101,
Thanks for your answer.
But how can I do this? I right-click in Design mode in the field I need, choose "Insert -> Insert condition" and...I see "Edit XPATH expression" again! I've seen it before. I can use IF there, but it does not work with XSLT 1.0.
Maybe I was not too specific. I'll try to explain what my problem is.
Imagine that in incoming file you have two tags: <flag> and <percentage>.
In outgoing PDF I need: if <flag> = 'False' I need -<percentage>*100, if <flag> = 'True' I need <percentage>*100 (without minus char).
What is the best way to implement it, if not IF statement?
Thank you so much
|
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 558
|
You don't use an XPath if. The condition cause the creation of the xsl:choose conditional construct in the generated XSLT.
So, the condition XPath in your case would simply be flag = 'False'. Then, inside the condition, you'll put an auto-calculation with '-percentage * 100'.
See the attached example.File Attachment(s): example.pxf (71kb) downloaded 149 time(s).
|
|
Rank: Newbie
Joined: 10/7/2020 Posts: 8 Location: Ukraine
|
K101 wrote:You don't use an XPath if. The condition cause the creation of the xsl:choose conditional construct in the generated XSLT. So, the condition XPath in your case would simply be flag = 'False'. Then, inside the condition, you'll put an auto-calculation with '-percentage * 100'. See the attached example.
Hello K101,
Thank you so much! I followed your advice and it worked just fine.
Thank you again!
|
|
guest |