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

XPath-Navigable-Document from Nodelist

I would like to select some nodes from a very large XML document and then
apply a stylesheet to the dom fragment / nodelist that is the result of my
XPath-Query.

It seems to me now that I have to build a new XMLDocument from the Nodelist
and apply the Stylesheet then. Is this realy neccessary or is there a simple
way to generate an "XPath-Navigable-Document" from my Nodelist wich I seem to
need for the XSLTransform?

This is the code where maybe just one statement is missing:

XMLOutput.Clear();
XmlTextReader tr = new XmlTextReader(textBox3.Text);
XmlValidatingReader vr = new XmlValidatingReader(tr);
vr.Schemas.Add("", textBox1.Text);
vr.ValidationType = ValidationType.Schema;
vr.ValidationEventHandler += new ValidationEventHandler(MyValidationHandler);
// load document with validating reader
XmlDocument doc = new XmlDocument();
// if we get past this, we know document is valid
doc.Load(vr);
XmlNodeList list = doc.SelectNodes(Filter.Text);
label4.Text = list.Count.ToString();
//So I got my Nodelist / DOM-Fragment here in "list" now XslTransform
myXslTransform;

***** XPathDocument myXPathDocument = new XPathDocument(list); ***** //This
does not work! How to do this? *******

myXslTransform = new XslTransform();
myXslTransform.Load(textBox2.Text);

System.IO.StringWriter stWrite = new System.IO.StringWriter();
myXslTransform.Transform(myXPathDocument, null, stWrite);

XMLOutput.AppendText(stWrite.ToString());
Nov 12 '05 #1
1 1700
Chucker wrote:
I would like to select some nodes from a very large XML document and then
apply a stylesheet to the dom fragment / nodelist that is the result of my
XPath-Query.

It seems to me now that I have to build a new XMLDocument from the Nodelist
and apply the Stylesheet then. Is this realy neccessary or is there a simple
way to generate an "XPath-Navigable-Document" from my Nodelist wich I seem to
need for the XSLTransform?


No, you don't have to create new document. Instead you can pass selected
nodeset (as XPathNodeIterator) as a parameter to XslTransform and
process it in XSLT.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
6
by: Scott Simpson | last post by:
What is a good tool for running XPath queries on Linux? I have the O'Reilly XPath book and I'm using XPath Visualizer on Windows and that seems to work fine, but I'm looking for something on Linux....
3
by: gimme_this_gimme_that | last post by:
I once downloaded a shareware program that allowed you to open an xml file, click on a text or an attribute, an then see the xpath expression that would fetch that data. The program didn't...
4
by: Bnaya Eshet | last post by:
I do like XPath, I really do. But I'm working on the compact framework which XPath is not included. So I come to understanding that if XPath do not come to the mountain,
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
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>
7
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...
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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 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.