Solved

cut off part of the strintg XSL FO

Posted on 2009-07-01
7
741 Views
Last Modified: 2013-11-18
Hello Guys

is it possible to get rid of part of the string (do not display it at the pdf) in xsl fo file?

 for example here i need to cut off (in THB) :
some company name (in THB)
another company name (in THB)
etc....

if it was just one off string i could do:

<xsl:if test="@companyName='some company name (in THB)'">
some company name
</xsl:if>

however the company name will be always different! so i need to cut the part of string (in THB) only off!

is it possible to do at XSL FO?

<xsl:if test="@companyName='some company name (in THB)'">

some company name

</xsl:if>

Open in new window

0
Comment
Question by:nzrubin
  • 4
  • 3
7 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 24761251
something like this will do that
    <xsl:value-of select="substring-before(., '(in')"/>
    <xsl:value-of select="substring-after(substring-after(., '(in'), ')')"/>

If you have multiple unlknown company strings in one elemen, you will need some recursive processing, let me know if that is the case

If you can use XSLT2.0 (highly recommended when you need string processing) tell me too
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24761261
Look how elegant a XSLT2 solution is for multiple companies
    <xsl:analyze-string select="." regex="\(\s*in[^\)]*\)">

        <xsl:non-matching-substring>

            <xsl:value-of select="."></xsl:value-of>

        </xsl:non-matching-substring>

    </xsl:analyze-string>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24761268
Please note that allthough your FO processor might not support XSLT2,
XSL-FO processors don't need to do the XSLT stuff themselves.
In my XSL-FO projects I never use the built in XSLT processor,
I always use Saxon9B for the XSLT part, so I can use XSLT2
and I only use the FO processor for dealing with the FO to PDF rendering
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 4

Author Closing Comment

by:nzrubin
ID: 31598973
hi Gertone: it works!
for some reason i couldnt find this info in the internet...
in the close future ill need to ask some more questions.  Will you monitor? how can you first check out the questions?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24767774
In his grading comment (not visible to all) the asker posts
> in the close future ill need to ask some more questions. Will you monitor? how can you first check out the questions?
Here is my answer:

All XSLT questions are prompted via email.
Anyone interested in receiving a notification for XSLT questions gets an email if you post a question.
I read them and many other experts do too.
This way it is likely that you get an answer to your questions really fast

cheers
0
 
LVL 4

Author Comment

by:nzrubin
ID: 24768951
just found out that it cuts fine, but if there is no character in the string that i indicate  to cut before ... the string just displays nothing!

for example i want to display all string in front of  (  
but if no bracket in the string --- the string is not displays at all!  
0
 
LVL 4

Author Comment

by:nzrubin
ID: 24769224
found work around it



<xsl:choose>

											<xsl:when test="substring-before(@billingCompany,' (')=''">

												<xsl:value-of select="@billingCompany"/>

											</xsl:when>

											

											<xsl:otherwise>

												<xsl:value-of select="substring-before(@billingCompany,' (')"/>												

											</xsl:otherwise>

										</xsl:choose>

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now