 |
| 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
|
|
|
|

January 29th, 2008, 10:06 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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 -/
|
|

January 29th, 2008, 11:25 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 29th, 2008, 11:33 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 29th, 2008, 11:44 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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 -/
|
|

January 29th, 2008, 12:01 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

January 30th, 2008, 05:36 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 30th, 2008, 06:29 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

January 30th, 2008, 08:31 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 30th, 2008, 09:34 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

January 30th, 2008, 10:06 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |