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

XPath as XML attribute

Hi all,

I'm a newbie to XSLT working on my first project with it and I'm stuck
on a particular thing.
I want to create a document that will write the PCDATA from a given
<Lineelement, then, in the next table cell, I want to insert the text
within the element pointed to by the "xpath" attribute.
<Line num="1" xpath="Income/Additions/CashFlow">Cash Flow for
2005</Line>
<Line num="2" xpath="Additions/AddDeductions/Total">Total Deductions
for 2005</Line>
<Line num="3"
xpath="Additions/AddDeductions/InterestPaidCorporateStockhold">Interest
paid to all corporations</Line>

I've tried
<xsl:for-each select=".">
<td>
<xsl:value-of select="@xpath" />
</td>
</xsl:for-each>
but it only outputs the text as PCDATA rather than retrieving the text
in the XML element. Is there any thing I can do to have the attribute
act as an XPath expression?

Thanks

Aug 11 '06 #1
2 1470


bi*******@gmail.com wrote:

Is there any thing I can do to have the attribute
act as an XPath expression?
Not with XSLT/XPath 1.0 as standardized, you have to look at extensions
which are then not necessarily implemented by the XSLT processor you use.
EXSLT.NET (<http://www.xmlmvp.org/exslt/index.html>) has this extension
function
<http://www.xmlmvp.org/exslt/GDNDynamic-evaluate.xml>
thus if you use .NET and are able to install EXSLT.NET then you can use
that function.

If you can't use an extension function then your only way with standard
XSLT is to generate a new stylesheet and then apply it.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 12 '06 #2
If you can't use an extension function then your only way with standard
XSLT is to generate a new stylesheet and then apply it.
I took your advice and I've written a stylesheet that generates a
stylesheet but (and correct me if I'm wrong) I was assuming that the
XSLT stylesheet that I wrote would generate the stylesheet which would
in turn generate an html document. I've written a stylsheet but all it
does it transform it into another stylesheet, it doesn't automatically
turn it into HTML. Is there some kind of instruction that you
specifically have to give in order to make the stylesheet execute
twice? Thank you.

Martin Honnen wrote:
bi*******@gmail.com wrote:

Is there any thing I can do to have the attribute
act as an XPath expression?

Not with XSLT/XPath 1.0 as standardized, you have to look at extensions
which are then not necessarily implemented by the XSLT processor you use.
EXSLT.NET (<http://www.xmlmvp.org/exslt/index.html>) has this extension
function
<http://www.xmlmvp.org/exslt/GDNDynamic-evaluate.xml>
thus if you use .NET and are able to install EXSLT.NET then you can use
that function.

If you can't use an extension function then your only way with standard
XSLT is to generate a new stylesheet and then apply it.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 22 '06 #3

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
9
by: Iain | last post by:
I want to create an XML configuration file which might look like <REGION Name="Europe" WingDing="Blue"> <COUNTRY Name="UK" WingDing="white"> <TOWN Name="London" WingDing="Orange" /> </COUNTRY>...
2
by: GIMME | last post by:
For starters .... If : //input is the xpath syntax to see if an element with an attribute named start_date exists ... Then what is the xpath syntax to return elements having
4
by: Abhinav | last post by:
Hi, I have the following XML : <checkIn bug="1111111"> <regression> </regression> </checkIn> How do i get the value "1111111" for bug ?
2
by: David Gordon | last post by:
Hi Folks, I wonder if anyone can help me with the following (perhaps trivial) problem: <xml> <node name="a" type="a"/> <node name="b" type=""/> <node name="c"/> <node name="d" type="b"/>...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
3
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? <GetRoleCollectionFromUser...
2
by: Grant Merwitz | last post by:
Hi, i'm not sure if this is the appropriate topic. But here goes: I am currently bulding a site menu from a xml file. I have an attribute that indicates whether an option is active or not...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
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.