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 April 3rd, 2008, 01:49 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sam,

When i am using the code below:

<xsl:stylesheet xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" exclude-result-prefixes="java" version="2.0" >

<xsl:output omit-xml-declaration="yes" />

<xsl:variable name="varPayload" select="datastream/payload" />
<xsl:variable name="varRecordBreak" select="'#x0A;'"/>
<xsl:variable name="varFieldDelimiter" select="','" />




<xsl:template match="/datastream/payload">

<xsl:variable name="tokens" select="str:tokenize(., '#x0A;')"/>
<xsl:variable name="headers" select="str:tokenize(normalize-space($tokens[1])),$varFieldDelimiter)"/>
    <xsl:variable name="varProprietaryDocumentIdentifier" select="$headers[2]" />
                  <xsl:variable name="varRevisionNumber" select="$headers[3]" />
                  <xsl:variable name="varGlobalBusinessIdentifier_Sold" select="$headers[4]" />
    <xsl:variable name="varGlobalBusinessIdentifier_Bill" select="$headers[5]" />
                  <xsl:variable name="varGlobalBusinessIdentifier_Ship" select="$headers[6]" />
    <xsl:variable name="varAccountNumber" select="$headers[7]" />
                  <xsl:variable name="varDateTimeStamp" select="$headers" />
                  <xsl:variable name="varGlobalDocumentFunctionCode" select="$headers[9]" />

<xsl:for-each select="$tokens">
  <xsl:if test="position() > 1 ">
    <xsl:variable name="details" select=="str:tokenize(normalize-space(.)),$varFieldDelimiter)"/>


                  <xsl:variable name="varLineNumber" select="$details[3]" />
                  <xsl:variable name="varGlobalProductIdentifier" select="$details[6]" />
                 <xsl:variable name="varDateStamp" select="$details[7]" />
                  <xsl:variable name="varProductQuantity" select="$details" />
                  <xsl:variable name="varGlobalProductUnitOfMeasureCode" select="$details[9]" />
     <xsl:variable name="varMonetaryAmount_GROSS" select="$details[10]" />
                  <xsl:variable name="varMonetaryAmount_NETT" select="$details[11]" />
                   <xsl:variable name="varGlobalDocumentReferenceTypeCode" select="$details[12]" />

<GlobalDocumentFunctionCode><xsl:value-of select="$varGlobalDocumentFunctionCode" /></GlobalDocumentFunctionCode>
<AccountNumber><xsl:value-of select="$varAccountNumber" /></AccountNumber>
<GlobalBusinessIdentifier><xsl:value-of select="$varGlobalBusinessIdentifier_Bill" /></GlobalBusinessIdentifier>
<DateTimeStamp><xsl:value-of select="$varDateTimeStamp" /></DateTimeStamp>
<ProprietaryDocumentIdentifier><xsl:value-of select="$varProprietaryDocumentIdentifier" /></ProprietaryDocumentIdentifier>
<RevisionNumber><xsl:value-of select="$varRevisionNumber" /></RevisionNumber>
<GlobalDocumentReferenceTypeCode><xsl:value-of select="$varGlobalDocumentReferenceTypeCode" /></GlobalDocumentReferenceTypeCode>
<GlobalProductUnitOfMeasureCode><xsl:value-of select="$varGlobalProductUnitOfMeasureCode" /></GlobalProductUnitOfMeasureCode>
<LineNumber><xsl:value-of select="$varLineNumber" /></LineNumber>
<ProductQuantity><xsl:value-of select="$varProductQuantity" /></ProductQuantity>
<GlobalProductIdentifier><xsl:value-of select="$varGlobalProductIdentifier" /></GlobalProductIdentifier>
<DateStamp><xsl:value-of select="$varDateStamp" /></DateStamp>
<xsl:value-of select="$varMonetaryAmount_GROSS" />
<xsl:value-of select="$varMonetaryAmount_NETT" />
<GlobalBusinessIdentifier><xsl:value-of select="$varGlobalBusinessIdentifier_Ship" /></GlobalBusinessIdentifier>
<GlobalBusinessIdentifier><xsl:value-of select="$varGlobalBusinessIdentifier_Sold" /></GlobalBusinessIdentifier>

 </xsl:if>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Then i am getting an error as:

Caused by: javax.xml.transform.TransformerConfigurationExcept ion: javax.xml.transform.TransformerConfigurationExcept ion: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Extra illegal tokens: ',', '$', 'varFieldDelimiter', ')'
    at org.apache.xalan.processor.TransformerFactoryImpl. newTransformer(Unknown Source)
    at com.gsk.gskgaa.utils.MessageUtil.processXML(Messag eUtil.java:556)



 
Old April 3rd, 2008, 02:03 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well delete the extra ')' in the headers variable line then.

/- Sam Judson : Wrox Technical Editor -/
 
Old April 3rd, 2008, 02:21 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sam...I have deleted but then too same error is coming

 
Old April 3rd, 2008, 02:56 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well if its the same error then either the line still isn't fixed or the same type of error is in place elsewhere This is where your ability to debug come in. Try running the transformation through the Saxon processor as its error messages are often much more helpful (and give line numbers). Check all the other places you use the str:tokenize() function. I also notice a double '==' on the details variable line that wont help things.

/- Sam Judson : Wrox Technical Editor -/
 
Old April 3rd, 2008, 04:38 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

str:tokenize(normalize-space($tokens[1])),$varFieldDelimiter)

Surely you can check the number of left and right parentheses for yourself and see that they don't match, rather than posting to a forum and expecting someone else to do it for you?

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

Thanks Sam and Michael for concerning my problem and providing me the solution.I have got
what i expected.

Thanks:)

 
Old April 4th, 2008, 03:10 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Sam,

When i give the input as blank for one of the field,in a csv file,then it is taking the next value as an input for that mapping in xml.
The input is like:
OH,1,,3,4,5,6
OD,1,2,5,7,8,9

Then it is taking value 3(third field) for the mapping of second field .


 
Old May 7th, 2008, 08:43 AM
Authorized User
 
Join Date: Jan 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sam,I have input as CSV file
a,b,,d
when there is no space in betwen delimiter then for the mapping of 3rd field it takes d as value for it.
But when i change the input as:
a,b, ,d
On placing a single space for that field in input csv file it maps d at correct place.
I am using str:tokenize() function in my xslt.
please solve my this problem.






Similar Threads
Thread Thread Starter Forum Replies Last Post
comapring global variable value to local variable amhicraig XSLT 6 December 5th, 2007 12:16 PM
Client-side variable feffe General .NET 0 May 9th, 2006 03:35 AM
Returning primary key into asp local variable! jowjow Oracle ASP 0 April 5th, 2006 09:06 AM
How to store ntext or text value to local variable ramk_1978 SQL Server 2000 3 September 14th, 2005 07:59 PM
sharing a server-side variable with client-side pigtail Javascript How-To 6 November 4th, 2004 02:01 AM





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