IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Using pure XSLT in Altova StyleVision Options · View
MichaelUA
Posted: Thursday, October 8, 2020 7:38:15 AM
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.
K101
Posted: Friday, October 9, 2020 8:56:12 AM
Rank: Advanced Member

Joined: 2/27/2009
Posts: 558
Why not simply use StyleVision's own condition functionality? That works using XSLT 1.0.
MichaelUA
Posted: Friday, October 9, 2020 9:58:45 AM
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
K101
Posted: Friday, October 9, 2020 11:05:26 AM
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).


MichaelUA
Posted: Thursday, October 29, 2020 4:25:44 PM
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!
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.