Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: I don't understand the scope of accessing XML elements...

From: Martin Honnen <mahotrash@-----.-->
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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent