Solved

cut off part of the strintg XSL FO

Posted on 2009-07-01
7
770 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

630 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