For part 2, it's hard to answer without seeing more context, but
usually it's because the XPath isn't running with the same namespace
prefix context as the XML.
For example, you might have xmlns:om="xyz" on the root template, but
not on some subsequent template.
I'm not using XSLT. I'm using XmlDom in C#.NET 1.1 and trying to return the XML fragment for further parsing. Of course, I always test my XPath in Stylus Studio GUI first.
So if this wasn't one of those cases where I had to use the local-name clause, I would say something this:
/MetaModel/Element/Element/Element/Element[Property/@Type="MessageName" and Property/@Value="xxxxx"]
So the brackets would be my predicate after the last element node that I want.
With the local-names, it becomes 3 times harder...
Maybe something like this:
/*[local-name()='MetaModel']/*[local-name()='Element']/*[local-name()='Element']/*[local-name()='Element'][local-name()='Element'][Property/@Type="MessageName" and Property/@Value="msgConProcReq"]
but this gives 0 hits, because Property name cannot be referenced without the local-name clause.
I want to get the same type of data for one specific element.
Thus I wish to qualfiy or add a predicate to the above to limit based on the value of an attribute on the child.
Property is a child of the lowest element, and Property has two attributes, @Name and @Value.
If I add this to the above, then the axis shifts from the element to the property, and I only get the property:
/*[local-name()='Property' and namespace-uri()='http://schemas.microsoft.com/BizTalk/2003/DesignerData' and @Name='MessageName' and @Value='msgConProcReq']
I have also tried adding the same predicate as above without the /* at the beginning, then I get 0 hits.
Thanks, I'm just thinking out-loud and trying to give good examples for future people who have issues in this area.
Can you go back up the tree after a predicate in pure XPATH? such as this?
/*[local-name()='Property' and namespace-uri()='http://schemas.microsoft.com/BizTalk/2003/DesignerData' and @Name='MessageName' and @Value='msgConProcReq']/*[..]
This (above) returns 0 hits, but the following runs and still returns the Property only: