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
<Line> element, 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

0
bignass04 (2)
8/11/2006 6:18:57 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
401 Views

Similar Articles

[PageSpeed] 38


bignass04@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/
0
mahotrash (1778)
8/12/2006 5:54:10 PM
> 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:
> bignass04@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/

0
bignass04 (2)
8/22/2006 3:41:21 PM
Reply:

Similar Artilces:

XPath
Using XPath I am querying parts of XML document, " get quoted by \ - is it possible to specify not to quote " with \? <RootElement> <Element Attribute="SomeValue" /> </RootElement> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); XmlNode xmlNode = xmlDoc.SelectSingleNode("//RootElement/Element") Print xmlNode.OuterXml <Element Attribute=\"SomeValue\"/> where I was expecting to get <Element Attribute="SomeValue"/> TIA Dennis wrote: > Using XPath I am querying parts of XML document,...

Loading xml schema from database
The XmlDataDocument can load xml from a string <script> string sXml = "<Root><Elemenet>Example</Element></Root>"; xdd.LaodXml(sXml) <.script> The question is, can I load a xml schema the same way(with string i retrieve from a databas)? I wand to load the schema into a DataSet or into a XmlDataDucument, and use the document DataSet member. Thank you ZAky ...

Getting a specific parent of any node via xpath navigation
I am storing my site structure as such: <menuItems> <menuItem> <pageID>1</pageID> </menuItem> <menuItem> <pageID>2</pageID> <menuItem> <pageID>4</pageID> <menuItem> <pageID>5</pageID> <menuItem> <pageID>6</pageID> </menuItem> </menuItem> </menuItem> </menuItem> <menuItem> <pageID>3</pageID> ...

XML Nodes conversion to Hashtable
Hi m not able to convert the node values of a XML file to Hashtable Actaully i need to traverse the XML Nodes again and again and want to pick values on filters what i want is to stroe the XML values in the Hashtable and return then from Hashtable (the hashtable will be filled only once) this will optimise the performance because the XML is not updated (or updated rarely) Thanks in advance On Sat, 25 Nov 2006 04:59:01 -0800, Manish wrote: > Hi m not able to convert the node values of a XML file to Hashtable > > Actaully i need to traverse the XML Nodes again and again and ...

Reading from XML into SP
This is a multi-part message in MIME format. ------=_NextPart_000_010A_01C34ACC.BED1CC30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hi,=20 I have a xml file.=20 And i want to be able to read those values into a stored procedure.=20 The XML structure is=20 <cash>=20 <tag section=3D1 id=3D1 param=3D2 param3=3D3 />=20 <tag section=3D1 id=3D2 param=3D2 param3=3D3 />=20 <tag section=3D2 id=3D1 param=3D2 param3=3D3 param4=3D4 />=20 <tag section=3D2 id=3D2 param=3D2 param3=3D3 param4=3D4 />=20 <tag secti...

Timeout when xml validating?
Hello. I have a document schema which imports the schema of four other documents. The problem is that when validating a document in the multiple import scenario, I get a timeout and then it complains that one of the individual documents root element is not defined. Is there a way to up the timeout value for validating through xmlvalidatingreader? Or another way? This is not exactly an http request, where you can physically set a timeout property. Thanks in advance. Adam *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for i...

XPath pb
Hi In infopath, I use a XPath expression to get some nodes : var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail"); My problem is that this method returns 0 items. Here is the DOM.xml property : <?xml version="1.0" ?> <?mso-infoPathSolution productVersion=\"11.0.5329\" PIVersion=\"1.0.0.0\" href=\"file:///C:\Documents%20and%20Settings\t-stevbe\Local%20Settings\Appli cation%20Data\Microsoft\InfoPath\7ab6e8af39fc42e2\manifest.xsf\" solutionVersion=\"1.0.0.9\" initialView=\"messagesList\" ?> <?...

CRM attribute field
Hello, I have a Custom Attribute nvarchar type and format URL, but Microsoft CRM automatically adds http:// to whatever the user enters. I want to make this field to accept paths like "C:\notes\data\test.doc" or "\\server\notes\data\test.doc" How can i do this? Tanks Hi, just don´t format it as URL cause in this case CRM defines URL not as a network UNC path. You´ll have to use javascript and for example a custom button to get access to the UNC path right if you´re clicking this custom button. Best regards "CRM Data Import" wrote: > ...

How to pass a Nodeset to an XPath extension function?
I am using the .NET framework v2.0.40607 with Visual C# Express and I would like to create some custom XPath functions to use directly in a XSLT stylesheet. I called System.Xml.Query.XmlArgumentList.AddExtensionObject(string, object) to register the functions I've written. The functions that take a String, Boolean or Number parameter work perfectly. However, I do not know how to create a function that will accept a Nodeset as a parameter. I tried writting a function taking a XPathNavigator object, but it does not work for all XPath queries that return a Nodeset: I get an error &qu...

XPath Validation
I'm looking for a way to Validate an XPath prior to executing the expression, without using a try catch clause. For example: I'm looking for something that would tell me that "\some/Xpath\to\Node" is invalid... Any Ideas? Hi, As far as I know, the .NET framework could not validate XPath directly with class library. The only thing we can do is to use try/catch block. Or you can try to find some 3rd-party tool such as XML spy to validate it. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Thanks K...

Xpath with namespaces
Hello Everyone, I am having an issue with xml and namespaces, at least I think it is namespaces. When I use namespaces, I cannot use SelectSingleNode / SelectNodes as they always return 0/Nothing respectively. Anyone have any thoughts? Thanks in advance VB.Net 2005 WinXP Sp2 Test code: Dim objXML As System.Xml.XmlDocument 'Test XML 1 ==> Always returns 0 objXML = New System.Xml.XmlDocument objXML.Load(Application.StartupPath & "\xmlfile1.xml") MsgBox(objXML.SelectNodes("top/middle").Count) 'Test XML 2 ==> Always re...

Attribute for Exchange storage group admin.
I am looking for a way to write a script that will look at each storage group in exchange 2003 and tell me who has administrative rights. Unless there is a report that exists that can do the same thing. Thanks, Mark Cooper ...

Load XML to DataSet Problem
The following is a small sample of my XML Data. When I load it to a dataset it only loads the 'Zone' elements and ignores loading the 'Field' elements. <zone id="1234" name="EMPLOYMENT_INFO"> <field change-date="00:00:00:000" display="true" editable="true" name="SBSB_CK" valid="true">22514850</field></zone> <zone id="1235" name="SUBSCRIBER_INFO"> <field change-date="00:00:00:000" display="false" editable="true" name=&qu...

Tricky XPath query
Hi all, I've just changed the structure of my XML file and now I need to construct an XPathNavigator object that uses tags from two different levels in the XML file. For example: <someTag> <innerTagA> <innerInnerTagA> <innerInnerInnerTagA> Some Data That Belongs Here </innerInnerInnerTagA> <innerInnerInnerTagB> Some Data that Belongs More Specifically Here </innerInnerInnerTagB> </innerInnerTagA> <innerInnerTagB> <innerInnerInnerTagZ> This Data should real...

Related attributes in View
Is it possible to see attributes of related-to entities in a view in MSCRM 3.0? It does seem to be possible to filter/query using these attributes, but not to expose them to the view? TIA ...

xml node
Hello, How can I get a xml node from a XmlTextReader? Thanks a lot! *** Sent via Developersdex http://www.developersdex.com *** juli jul wrote: > How can I get a xml node from a XmlTextReader? The XmlTextReader itself has no method for that but you can pass the reader to the method ReadNode of an XmlDocument object which then creates the node. Here is a simple example that uses the reader to read through an XML document, looking for an element node with node name 'god' and then creates an XmlElement of that: XmlTextReader xmlReader = new XmlTextReader(args[0]); ...

xpath??
Hi, I am very new to xml. I have a datatable I need to group by and was suggested that xml and xpath might be the way to go. I converted the datatable to xml but don't know what to do next. Can anyone point me to the right direction. This is what I am trying to do: - have datatable (~300k rows and 5 cols) - need to group by column1(string catagory) and column2(date) - display the totals by column1 and column2 in datagrid. Any help is appreciated. Thanks. The advice to convert the database to XML was clearly a bad joke. RDBMSes are best at what they can do best -- work with relational da...

loading XML into collection slow
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use the appointment collection to populate the calendar control. The performance getting the XML data is fine, but loading the data into the collection is slow. My question/problem is should I be using the collection, a dataset, or something else to load the xml data into the calendar control? Thanks, Kurt Bauer Kurt, How are you loading the Xml data into the collection? If you could post code or pr...

Show XML-File in TreeView
Hi, I have to show an xml-file in a treeview within a GUI. It should be possible to change the treeview via buttons while the prog is running, and at the exit of the GUI the current treeview should be saved in an xml-file. That it's possible to load the file later on if wanted. I havn't done anything like this befor, I hope that it is possible. thanks for your help. manuel There is no UI feature which impossible. But your features are not applied by Default Control, and you shoud be implement your own tree control. Please check the codeproject and find such projects. -- WebSit...

IE and XML problem.
I'm having trouble convincing IE to display my XML when I'm using it in my application. I'm creating XML using XmlTextWriter, and then Load() it to IE. The problem is that in the way, a space is inserted after every character (Like this < ? x m l v e r s i o n = " 1 . 0 " ? >) Which isn't valid XML, of course. Here is my code: private void ShowHtml(Item item) { ShowHtml(RoarApp.CurrentApp.ItemToXml(item));//Generate VALID XML } private void ShowHtml(string Html) { IPersistStreamInit Persist; Persist = RoarBrowser.Document as IPersistStreamInit; Persi...

Apply XSLT To XML File
I have an xml file in which I reference an xsl template file to convert the xml to HTML. My system also has VSNET 2003 installed and when I open the xml file in IE6 it opens the file in VSNET instead of processing the file with the stylesheet. How can I get the file to apply the stylesheet? Wayne in code, you do it something like this: System.Xml.XmlDocument doc= new System.Xml.XmlDocument(); doc.Load("MyXml.xml"); System.Xml.Xsl.XsltArgumentList xslArgs= null; System.Xml.Xsl.XslTransform xsl= new System.Xml.Xsl.XslTransform(); xsl.Load("MyXsl.xsl")); ...

Sorting with XPATH
Given an XML node List with the individual nodes looking like the following, what kind of XPATH statement can I use to sort the nodes by element F8 and inside F8 by element F3? <OffNetworkRequestPackage> <Transaction> <OffNetworkRequest> <OffNetworkData> <UserEmail>loretta.pelisserok@getronics.com</UserEmail> <AdminEmail>NoEmail</AdminEmail> </OffNetworkData> <xxirequest> <function uuid="SBPProcess" name="CBICashCheck" bpname="TellerStd"/> </xxirequest> <TF&...

XPath and namespaces
Hi; First off, I think I still do not understand exactly how we are supposed to handle namespaces when doing xpath queries under .NET so I may have some bad assumptions here. As I understand it, we need to set the namespaces on an XmlDocument - the ..NET libraries do not read it from the xmlns:... attributes in the xml. In our case we have to handle xml our customers will pass to our library so we do not know up front what namespaces will be in there or how they are set up. So we do the following: private void SetNamespace(XPathNavigator nav) { XPathNodeIterator list = nav.Select...

xml document content to xml element
hi all, i need to copy the content of a xml document and use it as xml element and insert into another xml document. Can someone tell me how? thank you "dotnetnoob" <dotnetnoob@discussions.microsoft.com> wrote in message news:C0627DA0-3839-404A-9D82-AEC8F4249648@microsoft.com... > hi all, > > i need to copy the content of a xml document and use it as xml element and > insert into another xml document. > > Can someone tell me how? This is fairly obvious: XmlDocument newDocument = new XmlDocument(); XmlDocument documentToCopy = new XmlDocument(); documen...

XPath with namespace
Hello all, I am working on an Add-in to the .NET framework using C#. I wanted to search the XML document using XPath but failed. The XML is like this: <unit xmlns="http://www.some.info/srcML" xmlns:cpp="http://www.some.info/srcML/cpp"> <aaa>something</aaa> </unit> The code I am using is as follows: XPathNavigator nav; XPathDocument docNav; XPathNodeIterator NodeIter; string fname="sth.xml"; docNav = new XPathDocument(@fname); nav = docNav.CreateNavigator(); nav.Evaluate(input); NodeIter = nav.Select(input); It works fine if there is n...