Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2008, 10:06 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Then you are back to recursion I'm afraid, although I'd probably use the substring-before() and substring-after() functions, instead of having to go out into java:

Code:
<xsl:template match="/">
  <xsl:call-template name="process">
    <xsl:with-param name="string" select="substring-before(data/payload, '#10;')"/>
    <xsl:with-param name="rest" select="substring-after(data/payload, '#10;')"/>
    <xsl:with-param name="position" select="1"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="process">
  <xsl:param name="string"/>
  <xsl:param name="rest"/>
  <xsl:param name="position"/>



   <xsl:call-template name="outputrecord">
     <xsl:with-param name="record" select="$string"/>
   </xsl:call-template>

  <xsl:if test="$rest != ''">
    <xsl:call-template name="process">
     <xsl:with-param name="string" select="substring-before($rest, '#10;')"/>
    <xsl:with-param name="rest" select="substring-after($rest, '#10;')"/>
    <xsl:with-param name="position" select="$position + 1"/>
  </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template name="outputrecord">
  <xsl:param name="record">
  <Record>
    <B_UT><xsl:value-of select="substring($record,1, 5)"/></B_UT>
    <EID><xsl:value-of select="substring($record,6, 11)"/></EID>
    <ADATE><xsl:value-of select="substring($record,17, 10)"/></ADATE>
    ...
  </Record>
</xsl:template>
/- Sam Judson : Wrox Technical Editor -/
 
Old January 29th, 2008, 11:25 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sam

When i tested with the code that you have provided am getting the below error

(Location of error unknown)XSLT Error (java.lang.OutOfMemoryError): null



 
Old January 29th, 2008, 11:33 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 Hi Sam

When i tested with the code that you have provided am getting the below error

(Location of error unknown)XSLT Error (java.lang.OutOfMemoryError): null

Is there any way of replacing the xalan processor with other processor that supports XSLT2.0 to my JRE


 
Old January 29th, 2008, 11:44 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I'm not very familiar with using Saxon in Java, but I know it supports the JAXP factory methods. Check the www.saxonica.com web site for more details. http://www.saxonica.com/documentatio...formation.html

/- Sam Judson : Wrox Technical Editor -/
 
Old January 29th, 2008, 12:01 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't really know what your difficulties are in running Saxon, you haven't explained much about your environment. It can be run using the same JAXP API that is used to run Xalan - though of course there may be things you have done to make transition difficult for yourselves.

Is this a one-off job or something that has to fit into a regular production cycle?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 30th, 2008, 05:36 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,

As per my knowledge I understood that, by default Xalan parser comes with the JRE, but as per your replies Xalan parser doesn't support the XSLT2.0

Am planning to replace the xalan parser with the some other parser(like Saxon) which supports the XSLT2.0 in JRE

Is it possible, if yes could you please suggest me how to do that


 
Old January 30th, 2008, 06:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's likely that you are invoking the transformation using

TransformerFactory factory = TransformerFactory.newInstance();

If that's the case, then in theory it should pick up Saxon automatically if Saxon is on the classpath. If it doesn't, then you can usually force it by setting the Java system property javax.xml.transform.TransformerFactory to the value "net.sf.saxon.TransformerFactoryImpl". You can do that using the -D option on the Java command line, or by calling System.setProperty() before instantiating the TransformerFactory.

If you still have difficulty, then replace the above line with

TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl();

(the only disadvantage of doing this is that you then have a compile-time reference to Saxon in your Java code, which means Saxon must be present whenever you compile).

You may need to check your code to see that you are not doing anything outside the scope of the JAXP interface that depends on Xalan.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 30th, 2008, 08:31 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,

I am not using any Java class, just i want to test the developed XSLT with the tokenize function

at present when i run that am getting error, because by default JRE is pointing to the Xalan parser

can i test that XSLT by downloading the saxon jar files by setting in classpath

is that will work or i need to fallow different method to work with the Saxon parser instead xalan parser



 
Old January 30th, 2008, 09:34 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Please explain how you are currently running your XSLT transformation.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 30th, 2008, 10:06 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,

Am using the internal client developed Adapter, that adapter is developed using the Java, there they have used the : jre 1.4

i think by default xalan pareser comes with the jre 1.4, that's why when i test the xslt using the adapter am getting the error

fallowing command am using to run the adapter

java FileSender sendXML.properties (just am using the adapter jar file)

Could you please explain me if i want to test the developed XSLT with the Saxon parser, just simply i need to download the saxon jar file and update the classpath is that will work?

and also confirm is XSLT2.0(tokenize) will work with the Saxon Parser









Similar Threads
Thread Thread Starter Forum Replies Last Post
Root Cause:java.lang.NoSuchMethodError: java.util. anees81 JSP Basics 3 March 1st, 2011 08:55 AM
java.lang.OutOfMemoryError: Java heap space meetkotresh J2EE 1 February 2nd, 2008 01:52 AM
java.lang.StackOverFlowError mrafeeq J2EE 1 August 10th, 2006 03:34 PM
java.lang.StackOverFlowError mrafeeq Pro Java 0 August 10th, 2006 12:51 PM
java.lang.Runtime mudasirw J2EE 1 August 2nd, 2005 02:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.