473,378 Members | 1,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

XML XSL Parsing problem with Xalan

Hi,
I have come across a tricky little problem, I hope maybe one of you
can help.
The problem I am having is that I need to parse two seperate values
from an XML document using XSL. The two elements however are identical
in their names and XPath appearing as below in the XML (I have left
out XPath as they are the same):
<esb:AcctTypeCode>43</esb:AcctTypeCode>
<esb:AcctTypeCode>21</esb:AcctTypeCode>

To get around this problem I used template matching, one for each
value, in the XSL to get the values as follows:
<!-- getLoanTypeCode Template -->
<xsl:template name="getLoanTypeCode"
match="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode">
<xsl:for-each select="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode">
<xsl:if test="position()=1">
<xsl:value-of select="node()"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- END getLoanTypeCode Template -->
<!-- getOriginalLoanTypeCode Template -->
<xsl:template name="getOriginalLoanTypeCode"
match="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode">
<xsl:for-each select="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode">
<xsl:if test="position()=2">
<xsl:value-of select="node()"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!-- END getOriginalLoanTypeCode Template -->

The main problem I need to solve, and I the reason I have posted here
is:
This works fine when I test the transformation with XMLSpy, however,
this does not work when I use Xalan for the conversion. When I run the
code I get the following exception:
[9/14/04 9:19:40:324 MDT] 4791004a SystemErr R
javax.xml.transform.TransformerConfigurationExcept ion:
javax.xml.transform.TransformerConfigurationExcept ion:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: A node test that matches
either NCName:* or QName was expected.
at org.apache.xalan.processor.TransformerFactoryImpl. newTransformer(TransformerFactoryImpl.java:718)
etc. etc.

I have tried this with a couple of versions of the Xalan and Xerces
jars including the ones from versions 2.6.0 and 2.6.2 of those
binaries so Idon't think it is a version problem, but it absolutely
has to do with the way I am getting the values because when I comment
out the template calls the parsing works fine (but obviously without
returning the values I want, if you know what I mean!).

Has anyone come across this problem before, or have any suggestions on
a possible fix or work-a-round?

Thanks,
littlefitzer
Jul 20 '05 #1
2 2184
hi,
The problem I am having is that I need to parse two seperate values
from an XML document using XSL. The two elements however are identical
in their names and XPath appearing as below in the XML (I have left
out XPath as they are the same):
<esb:AcctTypeCode>43</esb:AcctTypeCode>
<esb:AcctTypeCode>21</esb:AcctTypeCode>
no, the XPath experssions are not the same. Try:
<xsl:template name="getLoanTypeCode"
match="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode[1]">
<xsl:value-of select="node()"/>
</xsl:template>
and
<!-- getOriginalLoanTypeCode Template -->
<xsl:template name="getOriginalLoanTypeCode"
match="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode[2]">
<xsl:value-of select="node()"/>
</xsl:template>
<!-- END getOriginalLoanTypeCode Template -->


this works with saxon 6.5.
johannes

Jul 20 '05 #2
Thanks Johannes,
But I tried exactly what you say below, and I still get the same
error.
Also in XSMLSpy it did not work either - it returned a value of
'0InfoSuccess' for both.
Any other suggestions?

no, the XPath experssions are not the same. Try:
<xsl:template name="getLoanTypeCode"
match="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode[1]">
<xsl:value-of select="node()"/>
</xsl:template>


and
<!-- getOriginalLoanTypeCode Template -->
<xsl:template name="getOriginalLoanTypeCode"
match="./AccountRecord/esb:LoanAcctInfo/esb:AcctTypeCode[2]">
<xsl:value-of select="node()"/>
</xsl:template>
<!-- END getOriginalLoanTypeCode Template -->


this works with saxon 6.5.
johannes

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeroen N. Witmond | last post by:
Does anybody have ant experience with xalan http://xml.apache.org/xalan-c/overview.html on RedHat 9? Do you use the binary distribution for RH7.2 or did you build xalan from its source? Or did you...
0
by: Andy Fish | last post by:
Hi I am using Xalan-J 2.4.1 and I am trying to get the EXSLT node-set function working. xalan:nodeset() works fine but when I try exslt:node-set I get this error: (Location of error...
1
by: hongping | last post by:
I am having problems transforming a xml doc into html with proper indenting. Here is the xslt <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
0
by: Francesc Guim Bernat | last post by:
Dear colleagues, i'm getting in troubles using one XML library with Visual Studio .NET and Xerces with Xalan. (Xercer 2.4 and Xalan 1.7) When i execute the code i get the next run time error: ...
5
by: John | last post by:
I'm trying to generate HTML using a SAX TransformHandler. The problem I'm having is related to the xalan transformer using the shorthand notation when it writes out an empty textarea tag. My...
1
by: pgreaves | last post by:
hi there i have developed a style sheet that works fine in the XML perspective of Rational Software architect, but when i add it to my application, it appears to match no nodes. my XSL that...
0
by: gkaysen | last post by:
Hi all, could anybody tell me if and how it's possible to use Xalan's XPathAPI to evaluate an expression containing an extension function call against a xml document? Do I need to set...
5
by: Elhanan | last post by:
hi.. i don't exactly how to calls this , but is there a property for xalan, to output xml with crarriage return? i'm trying out xslt and the output can't be read with a normal editor, i know...
2
by: alex masselot | last post by:
Hello I'm not familiar with xerces in c++ Currently, we parse xml file with perl (typically XML::Twig) and java (dom4j). With both API, there is a very comfortable way to mix Sax/DOM, by...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.