Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Getting the parent when the child doesn't exist

From: "Greg Collins" <gcollins_at_msn_dot_com>
To: NULL
Date: 3/3/2009 10:50:00 AM
I'm posting this to both the XSL and C# newsgroups because it spans both.

I have an XPath passed to me that starts at the root node and goes down to a 
table row node. From this XPath I was grabbing the table node by appending a 
"/.." to the end of the XPath.

While this technique works great when the row exists, if the row does not 
exist, I can no longer identify the table node.

In code, one might say, well just rip off everything past the last slash 
character. This won't work because I cannot guarantee that a filter is not 
being used. And there might be nested filters and "[" and "]" characters 
used in the filter as values.

So what I need to find is a way to extrapolate the parent XPath from that 
which is passed in, but accounting for potential nested filters and [ ] 
characters used as filter values.

Anyone got any ideas? Here's a sample test XPath:

/ns:Root/ns:Branch[ns:Val1 = '[']/ns:Table[ns:Row/ns:Field1 = 
'[']/ns:Row[ns:Field2 = '[Test' and ns:Group1/ns:Field3[ns:Val2 = ']'] = 
'[']

What I need to get from it is the following:

/ns:Root/ns:Branch[ns:Val1 = '[']/ns:Table[ns:Row/ns:Field1 = '[']

I also cannot count on a namespace existing on the nodes. It might not.

Regex would be great (if even possible). Brute force works too.

Thanks ahead of time for any help.

-- 
Greg Collins
Microsoft MVP
Visit Braintrove at http://www.braintrove.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