473,387 Members | 1,549 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,387 software developers and data experts.

org/apache/xpath/objects/XObject incompatible with org/apache/xpath/objects/XNodeSet

Hello i tried this code in my stylesheet :

xsl:variable name="items"
select="xsl-usexsl:getElementsBySplitString(.,'i')" />

whith the java function getElementsBySplitString
here the code :

public static Element getElementsBySplitString(String aToSplit, String
aSeparator) throws UseXslException {

// Declaration
int intFound = 0;
// Trace
Log.debug(Constantes.CLE_METIER, mClassName,
"getElementsBySplitString : DEBUT");

try {
Element items= new Element("ITEMS");
if (aToSplit != null) {

intFound = aToSplit.indexOf(aSeparator);

while (intFound != -1) {
Element item = new Element("ITEM",aToSplit.substring(0,
intFound));
items.addContent(item);

aToSplit = aToSplit.substring(intFound + 1);
intFound = aToSplit.indexOf(aSeparator);
}

if (aToSplit.length() 0){
Element item = new Element("ITEM",aToSplit);
items.addContent(item);

}
}
// Trace
Log.debug(Constantes.CLE_METIER, mClassName,
"getElementsBySplitString : FIN");

return items;
} catch (Exception MyE) {
// Signalisation
Log.erreur(Constantes.CLE_METIER, "split : " + MyE.getMessage());

// Propagation
throw new UseXslException("Impossible de formater une chaine de
caractere en un Node");
}
}

and i get the following error :

org/apache/xpath/objects/XObject incompatible with
org/apache/xpath/objects/XNodeSet

Has someone anyidea for resolve this problem ?
thanks

Aug 9 '06 #1
4 2195
du********@hotmail.com wrote:
org/apache/xpath/objects/XObject incompatible with
org/apache/xpath/objects/XNodeSet
Xalan will recognize objects which implement the DOM's Element interface
as nodes -- but that probably isn't what you're returning (given that
you're using new Element(), which isn't a DOM method.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Aug 9 '06 #2

Joe Kesselman a écrit :
du********@hotmail.com wrote:
org/apache/xpath/objects/XObject incompatible with
org/apache/xpath/objects/XNodeSet

Xalan will recognize objects which implement the DOM's Element interface
as nodes -- but that probably isn't what you're returning (given that
you're using new Element(), which isn't a DOM method.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Thanks for your answer
I used an other solution for resolving my problem, i use a template
instead of java class

i found the following template :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
extension-element-prefixes="str">

<xsl:template name="str:split">
<xsl:param name="string" select="''" />
<xsl:param name="pattern" select="' '" />
<xsl:choose>
<xsl:when test="not($string)" />
<xsl:when test="not($pattern)">
<xsl:call-template name="str:_split-characters">
<xsl:with-param name="string" select="$string" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="str:_split-pattern">
<xsl:with-param name="string" select="$string" />
<xsl:with-param name="pattern" select="$pattern" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="str:_split-characters">
<xsl:param name="string" />
<xsl:if test="$string">
<token><xsl:value-of select="substring($string, 1, 1)" /></token>
<xsl:call-template name="str:_split-characters">
<xsl:with-param name="string" select="substring($string, 2)" />
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="str:_split-pattern">
<xsl:param name="string" />
<xsl:param name="pattern" />
<xsl:choose>
<xsl:when test="contains($string, $pattern)">
<xsl:if test="not(starts-with($string, $pattern))">
<token><xsl:value-of select="substring-before($string,
$pattern)" /></token>
</xsl:if>
<xsl:call-template name="str:_split-pattern">
<xsl:with-param name="string" select="substring-after($string,
$pattern)" />
<xsl:with-param name="pattern" select="$pattern" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<token><xsl:value-of select="$string" /></token>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

and then you can use it in your xsl stylesheet like this :

first we have a treeResult

<xsl:variable name="rtfSplits">
<xsl:call-template name="split" <xsl:with-param name="string"
select="string(.)" />
<xsl:with-param name="pattern" select="string(';')" />
</xsl:call-template>
</xsl:variable>

after tranform in nodeset
<xsl:variable name="vSplits" select="xalan:nodeset($rtfSplits)"/>

and after we can parse

<xsl:value-of select="$vSplits/token[1]"/>
<xsl:value-of select="$vSplits/token[2]"/>
<xsl:value-of select="$vSplits/token[3]"/>

Aug 10 '06 #3
du********@hotmail.com wrote:
I used an other solution for resolving my problem, i use a template
instead of java class
That works too. Named templates are often a reasonable substitute for
function calls. XSLT 2.0 makes that easier by adding the ability to
write XSLT code that can be invoked using function-call syntax.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Aug 10 '06 #4
(I should have added that one major advantage of doing it all in XSLT is
that your stylesheet is, obviously, more portable this way.)
Aug 10 '06 #5

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

Similar topics

2
by: betam4x | last post by:
hello all, i've just recently reinstalled windows, and i'm having a very bad problem with apache (win32) + mysql + php. For starters i installed everything like normal. Apache v. 2.0.50 PHP...
1
by: Johannes Lebek | last post by:
Hi there, I made some changes to my XSL stylesheet and now Xalan 2.5.1 is facing ClassCastExceptions. I'm pretty sure, that the changes I made should work (they are quite complicated -- I'd like...
7
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet...
1
by: Nels P. Olsen | last post by:
If you serialize an object graph to persist it somewhere (e.g. a database) between application sessions, then you run into trouble if the serialized objects' existing field order or datatypes change,...
2
by: dingbat | last post by:
Losing my marbles here (some sleep would help!) Why are the following XPath comparisons both returning false ? <xsl:value-of select="string('2005-09-22T12:43:23') &gt;...
2
by: Christoph | last post by:
Hello, I found the following XHTML document for testing sarissa's XPath implementation at http://sarissa.sourceforge.net/doc/. I replaced "Sarissa_0-9b3.js" in the test document below by...
9
by: **Developer** | last post by:
I do the following: Select Case mDataType(mColumnToSort) Case TypeCode.Int32 Result = CInt(xText).CompareTo(CInt(yText)) Case TypeCode.String
7
by: Tim Hallwyl | last post by:
Hi, there! As I understand the XPaht recommendation, the context node is a node; not a node-list, not XPath object -- but a single node. Now, the WS-BPEL 2.0 specification allows an XML simple...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.