In XSLT, is this possible to get value from xml using XPath
which is in XSLT variable?
I mean XPath strings can be dynamic while XSL Transforming.
If possible, How??
Because I'm not a native English speaker, it's quite hard
to make the problem clear. Please see the following example.
There are two XML files.
One has data, and the other has xpath. I will transform
the XPath XML.
for example,
* XPath XML
<xpaths>
<xpath>/students/student/name</xpath>
<xpath>/students/student/id</xpath>
</xpaths>
* Data XML : data.xml
<students>
<student>
<name>John Doe</name>
<id>234234</id>
</student>
</students>
* XSL snippet.
<xsl:template match="//xpath">
<xsl:variable name="xpathstring" select="."/>
<B>XPaht : <xsl:value-of select="$xpathstring"/></B>
<B>Value : <xsl:value-of select="document('data.xml')/$xpathstring" />
</B> </xsl:template>
As you know, that <xsl:value-of select(document(bla...)/> line
does not
work.
Any solution for this problem in XSLT?
I use JDOM/Xalan for transforming.
Thanks, 4 21175
Son KwonNam wrote: Any solution for this problem in XSLT? I use JDOM/Xalan for transforming.
Xalan should support
<http://www.exslt.org/dyn/functions/evaluate/index.html>
--
Martin Honnen http://JavaScript.FAQTs.com/
Thank you.
It works perfectly.
I attach the dyn:evaluate example XSL for someone who has the same
problem as mine. With xalan, no need to do anything to use dyn:evaluate.
Just use.
----------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:dyn="http://exslt.org/dynamic"
extension-element-prefixes="dyn"
<xsl:output method="xml"/>
<xsl:template match="/">
<ROOT>
<xsl:apply-templates />
</ROOT>
</xsl:template>
<xsl:template match="xpath">
<RESULT>
<XPATH><xsl:value-of select="."/></XPATH>
<xsl:variable name="xpathstr"
select="concat('document("data.xml")',.) "/>
<VALUE><xsl:value-of select="dyn:evaluate($xpathstr)"/></VALUE>
</RESULT>
</xsl:template>
</xsl:stylesheet>
Son KwonNam wrote: In XSLT, is this possible to get value from xml using XPath which is in XSLT variable?
I mean XPath strings can be dynamic while XSL Transforming.
If possible, How??
Because I'm not a native English speaker, it's quite hard to make the problem clear. Please see the following example.
There are two XML files. One has data, and the other has xpath. I will transform the XPath XML.
for example,
* XPath XML <xpaths> <xpath>/students/student/name</xpath> <xpath>/students/student/id</xpath> </xpaths>
* Data XML : data.xml <students> <student> <name>John Doe</name> <id>234234</id> </student> </students>
* XSL snippet. <xsl:template match="//xpath"> <xsl:variable name="xpathstring" select="."/> <B>XPaht : <xsl:value-of select="$xpathstring"/></B> <B>Value : <xsl:value-of select="document('data.xml')/$xpathstring" /> </B> </xsl:template>
As you know, that <xsl:value-of select(document(bla...)/> line does not work.
Any solution for this problem in XSLT? I use JDOM/Xalan for transforming.
Thanks, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MN |
last post by:
Hi All,
I have a string like ...
String str1 = "(15*20)+12.5";
I want to evaluate this string to get the mathematical output. Ideally
output will be 312.5. How can I do with the .Net??
...
|
by: TJS |
last post by:
How can I evaluate this string in vb.net
" Dim submenu0 As New skmMenu.MenuItem('Home', '') "
|
by: TJS |
last post by:
How can I evaluate this string in vb.net
" Dim submenu0 As New skmMenu.MenuItem('Home', '') "
I have tried this with skmmenu as a reference in the compile command but
assembly will not...
|
by: KenRoy |
last post by:
I want to be able to evaluate a string value as either True or False. So if
the string was "0 Or (1 or 0)" the value True would be returned. My ultimate
goal would be to have a statement similar...
|
by: darrel |
last post by:
I don't do a lot with XML, so I always get a bit lost navigating the XML
classes.
In the past, I've used this:
xslt.Transform(doc, xslArg, Response.Output, Nothing)
Which takes my xml file...
|
by: mat14 |
last post by:
Hi,
Is it possible to evaluate a string to get a logical output?
For Eg.
var string1 = "true && false || true"
Is there any method that i can use to evaluate this string and get an logical...
|
by: yarborg |
last post by:
This is kind of a weird one and hard to find answers online because of the format of the question.
Essentially I want to be able to have a string that looks like this "True AND True AND True" and...
|
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= |
last post by:
I have a custom business object of type Person.
i created a page with check boxes that will post to a second page that is
strongly typed with the first page and i have a function that retreives...
|
by: prao2005 |
last post by:
how to check whether the value of a string variable is Yes or No?
xsl;variable name="test1" select="DBE:OBJECT/DBE:ATTRIBUTE/DBE:String"/>
xsl;variable name="test2"...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
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...
| |