Problem with filtering xpath

J

jp

Hi

This seems to be too difficult to me :-(

My datasource is like this:
Requirements
Chapters
Chapter (Repeating)
ChapterTitle
ChapterDescription

Now I try to make function, which search ChapterTitle for example "Chapter1"
and if it exists set default value for that ChapterDescription field.
I enclosed my function. Problem with that, is that it write default
ChapterDescription text for the first chapter, not that one which was found
using the filter.
Why this happen? Is it something related to Namespaces.
How to get my function to work?

Best Regards
JP


function test(eventObj)
{
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-12-04T18:26:11"');

// XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-01-19T21:16:49"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
// if this is used Chapter1 cannot be found

var strXPathFilter = "//my:Chapter[//my:ChapterTitle=\"Chapter1\"]";

oTrgChapter = XDocument.DOM.selectSingleNode(strXPathFilter);
if (!oTrgChapter)
{
// Step 1.
//chapter not found

}
else
{
oTrgChapter.selectSingleNode("my:ChapterDescription").text = "Default
text"
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top