473,663 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:getEleme ntsBySplitStrin g(.,'i')" />

whith the java function getElementsBySp litString
here the code :

public static Element getElementsBySp litString(Strin g aToSplit, String
aSeparator) throws UseXslException {

// Declaration
int intFound = 0;
// Trace
Log.debug(Const antes.CLE_METIE R, mClassName,
"getElementsByS plitString : DEBUT");

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

intFound = aToSplit.indexO f(aSeparator);

while (intFound != -1) {
Element item = new Element("ITEM", aToSplit.substr ing(0,
intFound));
items.addConten t(item);

aToSplit = aToSplit.substr ing(intFound + 1);
intFound = aToSplit.indexO f(aSeparator);
}

if (aToSplit.lengt h() 0){
Element item = new Element("ITEM", aToSplit);
items.addConten t(item);

}
}
// Trace
Log.debug(Const antes.CLE_METIE R, mClassName,
"getElementsByS plitString : FIN");

return items;
} catch (Exception MyE) {
// Signalisation
Log.erreur(Cons tantes.CLE_METI ER, "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 2217
du********@hotm ail.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********@hotm ail.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:styleshe et 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($stri ng)" />
<xsl:when test="not($patt ern)">
<xsl:call-template name="str:_spli t-characters">
<xsl:with-param name="string" select="$string " />
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<xsl:call-template name="str:_spli t-pattern">
<xsl:with-param name="string" select="$string " />
<xsl:with-param name="pattern" select="$patter n" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="str:_spli t-characters">
<xsl:param name="string" />
<xsl:if test="$string">
<token><xsl:val ue-of select="substri ng($string, 1, 1)" /></token>
<xsl:call-template name="str:_spli t-characters">
<xsl:with-param name="string" select="substri ng($string, 2)" />
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="str:_spli t-pattern">
<xsl:param name="string" />
<xsl:param name="pattern" />
<xsl:choose>
<xsl:when test="contains( $string, $pattern)">
<xsl:if test="not(start s-with($string, $pattern))">
<token><xsl:val ue-of select="substri ng-before($string,
$pattern)" /></token>
</xsl:if>
<xsl:call-template name="str:_spli t-pattern">
<xsl:with-param name="string" select="substri ng-after($string,
$pattern)" />
<xsl:with-param name="pattern" select="$patter n" />
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<token><xsl:val ue-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:n odeset($rtfSpli ts)"/>

and after we can parse

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

Aug 10 '06 #3
du********@hotm ail.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
1846
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 v. 4.3.8 Mysql 4.1.4Gamma I then installed phpmyadmin, i noticed it was having a problem
1
8455
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 to not explain them here). My question is, is a ClassCastException a usual response in case of an error in a stylesheet or is this a bug? I thought, Xalan would handle exceptions like this internally.
7
4118
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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:my-javascript-ext="my-ext1" extension-element-prefixes="my-javascript-ext"
1
1544
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, or if the object is moved from one assembly or namespace to another. Even if we're careful about making such changes, we need to serialize object graphs which may contain objects defined by the user, and users are sure to make incompatible changes...
2
1786
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; string('2005-09-15T14:06:58')" /> <xsl:value-of select="string('2005-09-15T14:06:58') &gt; string('2005-09-22T12:43:23')" />
2
5383
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 "sarissa.js" from sarissa0.9.6.1. Loading the document Firefox replies "XML filtering predicate operator called on incompatible XMLDocument". What's wrong? Thanks in advance, Christoph
9
3007
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
2809
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 type value to be the context of an XPath expression, by converting it to an XPath object -- either boolean, string or float. I do not see how this is possible, but I would like your thoughts on it.
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.