Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cut off part of the strintg XSL FO

Posted on 2009-07-01
7
Medium Priority
?
776 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 2000 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
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.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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 look for a specific file type in a local or remote server directory using PHP.

722 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