wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Can we use xsl to remove substring methods from java file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Can we use xsl to remove substring methods from java file?" Watch "Can we use xsl to remove substring methods from java file?" New topic
Author

Can we use xsl to remove substring methods from java file?

zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi,

I am novice is xsl. Can you please tell me if I can format values using xsl in java file?

For example,

I have a dynamic value getting generated as : 435.agh.467

Basically, to remove agh out of it, I would use a substring version like so:



Actually I want to avoid this kind of substring in java file. Can someone please let me know if this is possible to do these sub string formatting in xsl file?


Help is greatly appreciated. Also, please explain the applications of xsl.


Thanks
Zahid
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Sure it is. There's a substring() function in XPath, which is used in XSLT. There's also substring-after() and substring-before().

Although I'm not sure what you mean when you say "in java file", which you said twice. You do know that XSLT can only be used to transform XML, don't you? Your question sounds like you want to do something to Java source code using XSLT.
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi Paul,

Actually my requirement is something like this:

I have a java file with a lot of substring methods in it. Basically I am trying to reduce those substring functions as those will make my program hard to read and involves more complexity.

For this reason, I am planning to change to xsl/xslt because I remember someone told me that this could be done using xslt. Now the question is how we can achieve it using xslt. What are the things need to be pre-written? Any good tutorial that you can suggest? Thanks


Zahid
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Okay. So you have some Java source code with lots of substring operations? And you plan to throw away that code and use XSLT instead? Is that what you are saying?

If so, then sure, go ahead and do that. I don't understand what you mean by "pre-written" but if you're asking what XSLT code you should use for a task that you haven't described at all, then I don't understand how you expect anybody could provide any answers for that.

If you google for "XSLT tutorial" you'll get a link to the w3schools pages about XSLT which are not very good at all. I don't recommend learning an entire language by reading Internet tutorials. Get a book and start there. Good luck with your project and if you have a specific problem with some XSLT code then don't hesitate to come here and ask it.
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi Paul,

Thanks for your reply. I will definitely google out for some books on XSLT tutorial and then will come back if I have any specific doubts. Appreciate your help.


Regards,
Zahid Zubair S
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we use xsl to remove substring methods from java file?
 
Similar Threads
Can I use java in XML file?
XML rendering in JSP
Need help with Substring
CSV to XML coding in Java
Dependent Combo Box