Hi there,
somehow, I cannot access nodes that are stored in a variable. I'm using
Xalan 2.5.1 and the following commands:
=============== = BEGIN =============== =====
<xsl:variable name="reference d-node" select="//a[@att1 = current()/@att2]"/>
<xsl:variable name="attribute-source">
<xsl:choose>
<xsl:when test="$referenc ed-node">
<xsl:copy-of select="$refere nced-node"/>
</xsl:when>
<xsl:otherwis e>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- line 556 follows -->
<!-- this is where the error occurs -->
<xsl:value-of select="$attrib ute-source/@att3"/>
=============== == END =============== ======
I cannot access $attribute-source. If the node or its attribute 'att3'
could not be found, nothing would be written. But even then no
ClassCastExcept ion should be thrown.
Is this problem caused by the <xsl:copy-of> statements? My understand is
that I can store the nodes in variable $attribute-source using
<xsl:copy-of>. <xsl:value-of> would not help in this case, because I
need the node and not its text value.
If I run Xalan, it tells me:
=============== = BEGIN =============== =====
; SystemID: file:///path/../../stylesheet.xsl; Line#: 556; Column#: 59
javax.xml.trans form.Transforme rException: java.lang.Class CastException
at
org.apache.xala n.templates.Ele mValueOf.execut e(ElemValueOf.j ava:330)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java(Co mpiled
Code))
at org.apache.xala n.templates.Ele mIf.execute(Ele mIf.java:203)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java:23 18)
at org.apache.xala n.templates.Ele mCopy.execute(E lemCopy.java:15 3)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java:23 18)
at
org.apache.xala n.templates.Ele mLiteralResult. execute(ElemLit eralResult.java :699)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java:23 18)
at
org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Transforme rImpl.java:2185 )
at
org.apache.xala n.transformer.T ransformerImpl. transformNode(T ransformerImpl. java:1263)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java :671)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java :1179)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java :1157)
at org.apache.xala n.xslt.Process. main(Process.ja va:1025)
---------
java.lang.Class CastException
at
org.apache.xpat h.axes.FilterEx prIteratorSimpl e.executeFilter Expr(FilterExpr IteratorSimple. java(Compiled
Code))
at
org.apache.xpat h.axes.FilterEx prWalker.setRoo t(FilterExprWal ker.java(Compil ed
Code))
at
org.apache.xpat h.axes.WalkingI terator.setRoot (WalkingIterato r.java(Compiled
Code))
at
org.apache.xpat h.axes.LocPathI terator.execute CharsToContentH andler(LocPathI terator.java:27 6)
at
org.apache.xala n.templates.Ele mValueOf.execut e(ElemValueOf.j ava:311)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java(Co mpiled
Code))
at org.apache.xala n.templates.Ele mIf.execute(Ele mIf.java:203)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java:23 18)
at org.apache.xala n.templates.Ele mCopy.execute(E lemCopy.java:15 3)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java:23 18)
at
org.apache.xala n.templates.Ele mLiteralResult. execute(ElemLit eralResult.java :699)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp plyTemplates.ja va:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja va:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor merImpl.java:23 18)
at
org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Transforme rImpl.java:2185 )
at
org.apache.xala n.transformer.T ransformerImpl. transformNode(T ransformerImpl. java:1263)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java :671)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java :1179)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java :1157)
at org.apache.xala n.xslt.Process. main(Process.ja va:1025)
=============== == END =============== ======
Any idea, how to access the node stored in $attribute-source?
Thanks in advance,
Johannes 1 2745
Thanks, Marrow, although I found a solution meanwhile, I have to admit
your's it much smarter!
Johannes
Marrow wrote: Hi Johannes,
Try something like this code...
<xsl:variable name="reference d-node" select="//a[@att1 = current()/@att2]"/> <xsl:variable name="attribute-source" select="$refere nced-node | (.)[not($referenced-node)]"/>
Hope this helps Marrow http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger) http://www.topxml.com/Xselerator
"Johannes Lebek" <re************ ****@domain.com > wrote in message news:bh******** **@sp15at20.hur sley.ibm.com...
Hi there,
somehow, I cannot access nodes that are stored in a variable. I'm using Xalan 2.5.1 and the following commands:
============= === BEGIN =============== =====
<xsl:variab le name="reference d-node" select="//a[@att1 =
current()/@att2]"/>
<xsl:variab le name="attribute-source"> <xsl:choose> <xsl:when test="$referenc ed-node"> <xsl:copy-of select="$refere nced-node"/> </xsl:when> <xsl:otherwis e> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:variable>
<!-- line 556 follows --> <!-- this is where the error occurs --> <xsl:value-of select="$attrib ute-source/@att3"/>
============= ==== END =============== ======
I cannot access $attribute-source. If the node or its attribute 'att3' could not be found, nothing would be written. But even then no ClassCastExce ption should be thrown. Is this problem caused by the <xsl:copy-of> statements? My understand is that I can store the nodes in variable $attribute-source using <xsl:copy-of>. <xsl:value-of> would not help in this case, because I need the node and not its text value.
If I run Xalan, it tells me:
============= === BEGIN =============== ===== ; SystemID: file:///path/../../stylesheet.xsl; Line#: 556; Column#: 59 javax.xml.tra nsform.Transfor merException: java.lang.Class CastException at org.apache.xa lan.templates.E lemValueOf.exec ute(ElemValueOf .java:330) at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java(Com piled
Code)) at org.apache.xala n.templates.Ele mIf.execute(Ele mIf.java:203) at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java:231 8)
at org.apache.xala n.templates.Ele mCopy.execute(E lemCopy.java:15 3) at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java:231 8)
at
org.apache.xala n.templates.Ele mLiteralResult. execute(ElemLit eralResult.java : 699)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java:231 8)
at
org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Transforme r Impl.java:2185)
at
org.apache.xala n.transformer.T ransformerImpl. transformNode(T ransformerImpl. j ava:1263)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java : 671)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java : 1179)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java : 1157)
at org.apache.xala n.xslt.Process. main(Process.ja va:1025) --------- java.lang.Cla ssCastException at
org.apache.xpat h.axes.FilterEx prIteratorSimpl e.executeFilter Expr(FilterExpr I teratorSimple.j ava(Compiled
Code)) at
org.apache.xpat h.axes.FilterEx prWalker.setRoo t(FilterExprWal ker.java(Compil e d
Code)) at
org.apache.xpat h.axes.WalkingI terator.setRoot (WalkingIterato r.java(Compiled
Code)) at
org.apache.xpat h.axes.LocPathI terator.execute CharsToContentH andler(LocPathI t erator.java:276 )
at org.apache.xa lan.templates.E lemValueOf.exec ute(ElemValueOf .java:311) at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java(Com piled
Code)) at org.apache.xala n.templates.Ele mIf.execute(Ele mIf.java:203) at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java:231 8)
at org.apache.xala n.templates.Ele mCopy.execute(E lemCopy.java:15 3) at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java:231 8)
at
org.apache.xala n.templates.Ele mLiteralResult. execute(ElemLit eralResult.java : 699)
at
org.apache.xala n.templates.Ele mApplyTemplates .transformSelec tedNodes(ElemAp p lyTemplates.jav a:425)
at
org.apache.xala n.templates.Ele mApplyTemplates .execute(ElemAp plyTemplates.ja v a:215)
at
org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Transfor m erImpl.java:231 8)
at
org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Transforme r Impl.java:2185)
at
org.apache.xala n.transformer.T ransformerImpl. transformNode(T ransformerImpl. j ava:1263)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java : 671)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java : 1179)
at
org.apache.xala n.transformer.T ransformerImpl. transform(Trans formerImpl.java : 1157)
at org.apache.xala n.xslt.Process. main(Process.ja va:1025)
============= ==== END =============== ======
Any idea, how to access the node stored in $attribute-source? Thanks in advance,
Johannes This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: K. N. |
last post by:
Is there any good and fast Python module for XSLT
processing ? I'm going to use XML and XSLT to generate
web pages, so I need XSLT processor that will be able
to transform for example a DOM object in memory - I
don't want to create XML file containing data and then
load it and transform with XSLT, but I want to do
this at once - without writing to a temporary file.
Actually I've seen alot articles about parsing XML,
but nothing about...
|
by: Martin |
last post by:
I have 5 days of experince with XSLT and I am sure my problem is
pretty much as basic as they come but I cannot work it out, so I hope
someone will take pity on me - please!
I have inherited an XML file format which has one header node and
several child nodes :
<wi workitemid= "99999" .... etc .... />
<widata dataname="AMOUNT" datadisplay="Amount" datavalue="123.45"/>
<widata dataname="ADDRESS1" datadisplay="Address" datavalue="Line
|
by: inquirydog |
last post by:
Hi-
Does anyone know a way to compare whether two nodes contain
the same information in xslt (the name, attributes, and all content
recursivly should be the same. I am interested in the case where node
ordering matters, and also the case where it doesn't, but perhaps that
is an advanced topic). Ideally the method should be available to
xpath expressions, so I think that creating new templates which
compare nodes will not work (well,...
|
by: Frederik Sørensen |
last post by:
I include a xslt stylesheet with variables for all the error messages in
my system.
<xsl:variable name="Banner_error_1">
errormessage 1 for banner
</xsl:variable>
<xsl:variable name="Banner_error_2">
errormessage 2 for banner
</xsl:variable>
|
by: cyclops |
last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains
multiple namespaces and XSLT will handle all possible tags under each
name space.
----source----
<document xmlns="..." xmlns:a="..." xmlns:b="">
....
----XSLT----
....
| |
by: Oleg Konovalov |
last post by:
Hi,
I am new to XSLT, trying to significantly modify somebody
else's XSL. That is not 2.0.
I need to create min & max variable(s)
to be used in many templates and sub-templates
based on certain conditions (not always).
It can't be calculated at the beginning of the file
|
by: Daniel Hilgarth |
last post by:
Hello,
I am currently trying to use XSLT for the creation of multiple
HTML-files from a single XML-File.
This HTML-files need to have links to each other.
The following information might be important:
There are some special nodes that will start a new HTML-page
("page-nodes"). Those nodes can be nested.
Those nodes have an attribute "name" which is not necessarily unique.
There are another special nodes that will create a link in one...
|
by: jkmyoung |
last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools.
Attribute Value Template
Official W3C explanation and example
This is when you want to put dynamic values in the attribute of an element. Instead of using the <xsl:attribute> element, you can simply place the xpath in the attribute itself.
The most common usage of this is in creating hyperlinks.
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |