Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  Mvp.Xml Project  XInclude.NET  xpointer suppor...
 xpointer support for id()
 
DIScorp
1 posts
Joined
2/22/2008

xpointer support for id()
Posted: 22 Feb 08 2:04 AM (Austria)
Hi!

I have detected a problem when using the function id() in a given xpointer.
An example for such an xpointer would be:
xmlns(etsi=http://uri.etsi.org/01903/v1.1.1#) xpointer(id('etsi-data-object-0-1202988076-81515437-29665')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)

In this case the Id-object would not be found because the function cannot be evaluated.

But I also found a solution for this issue - replace the function with ordinary xpath syntax using the following code inside the ParseXPointer class (plus adding a public property 'XPath' to XPointerSchemaPointerPart class):
-----------------------------------------------------------
CODE in C#:
...
case XPointerSchema.SchemaType.XPointer:
{
XPointerSchemaPointerPart xpointerPart = XPointerSchemaPointerPart.ParseSchemaData(lexer);
//check if id contained

string str = xpointerPart.XPath;
while (str.Contains("id("))
{
string strTmp = str;
int index = strTmp.IndexOf("id(", StringComparison.Ordinal);
int num2 = strTmp.IndexOf(")", StringComparison.Ordinal);

string ostrTmp = strTmp.Substring(index + 3, (num2 - index) - 3);
strTmp = ostrTmp.Replace("'", "").Replace("\"", "");
strTmp ="//*[@Id=\"" + strTmp + "\"]";

str = str.Replace("id(" + ostrTmp + ")", strTmp);
}
xpointerPart.XPath = str;

if (xpointerPart != null)
{
parts.Add(xpointerPart);
}
break;
}
...
-----------------------------------------------------------

So my question is: Does this approach make sense to you or do you have other suggestions?

Thanks for your help!
  Mvp.Xml Project  XInclude.NET  xpointer suppor...
Forum Home  Search