Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - I don't understand the scope of accessing XML elements... [Thread Next] Re: I don't understand the scope of accessing XML elements...To: NULL Date: 6/5/2008 4:48:00 PM Brian Kendig wrote: > I am having some trouble understanding the scope of the XML that's > passed to an XSL document. > > Let me provide an example. Say I have an XML document like this: > > <?xml version="1.0" encoding="utf-8"?> > <blog xmlns=""> > <blogPosts> > <blogPost id="47"> > <title>Blog post 1</title> > <author>Brian</author> > <date>2008/06/04</date> > <body>This is my first blog post</body> > </blogPost> > <blogPost id="52"> > <title>Blog post 2</title> > <author>Robert</author> > <date>2008/06/05</date> > <body>Second blog post.</body> > </blogPost> > </blogPosts> > </blog> > > And in my C# .NET code I've got this: > > XPathExpression path = XPathExpression.Compile("//blogPost[@id=47]"); > > When I pass it through an XSL transform, I can only access the child > elements of my blogPost as "//title", "//author", "//body", and so > forth. This seems imprecise to me, because if I happened to have an > element of the same name nested deeper in the blogPost element, it > might pick up the wrong element instead. But I don't understand why I > can't simply refer to the child elements as "title", "author", and > "body" - I don't know why the XSL simply doesn't see them. > > So, when I select part of an XML tree by compiling an XPathExpression, > what does the resultant XSL transform actually see? I can't follow you. Usually if you have an XPathExpression object, then you don't use it with XSLT but rather with the XPathNavigator API where you can pass in an XPathExpression to the Select or SelectSingleNode method. If you are doing something else then please show us the relevant code to enable us to understand how exactly you use XPathExpression. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
