Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cut off part of the strintg XSL FO

Posted on 2009-07-01
7
Medium Priority
?
787 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 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
Independent Software Vendors: 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!

 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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

824 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