JScript Issue

B

Brad Simon

Ok, I have to admit, I am no Jscript guru. I wanted to do all of this in
VBScript (and got is working in VBScript), and now I get an error that the
namespace is not declared in my document. I know that the XPath is correct,
and this still does not work. Here is my code:

eventObj.XDocument.DOM.selectSingleNode("//dfs:myFields/my:FileInfo/my:FullPath").text = eventObj.FileName

The exact error:
Reference to undeclared namespace prefix: 'dfs'.

I have tried changing the XPath to:
//my:myFields/my:FileInfo/my:FullPath
dfs:myFields/my:FileInfo/my:FullPath
my:myFields/my:FileInfo/my:FullPath
//myFields/my:FileInfo/my:FullPath
Many variations of the above

I still get an undeclared namespace prefix: 'x' on the ones with namespaces
in the name, and I get a null value for the XPaths that do not have any
namespace specified.

I would LOVE to do this in VBScript, but then I would have to recreate the
form from scratch (for the 10 millionth time) in order for it to get rid of
the JScript reference in the form (unless someone knows a way I can get
VBScript without rebuilding the form).

I am still finding it hard to believe that Microsoft put this product out
expecting developers to be able to do complicated tasks with it. This is the
worst version 1 application I have seen them put out in a long time. Doing a
task that would take me about 2 minutes in .NET (C# or VB) has taken me more
than 2 days to get it right here. I may not be the best programmer in the
world, but I am not THAT bad.
 
S

Steve van Dongen [MSFT]

Ok, I have to admit, I am no Jscript guru. I wanted to do all of this in
VBScript (and got is working in VBScript), and now I get an error that the
namespace is not declared in my document. I know that the XPath is correct,
and this still does not work. Here is my code:

eventObj.XDocument.DOM.selectSingleNode("//dfs:myFields/my:FileInfo/my:FullPath").text = eventObj.FileName

The exact error:
Reference to undeclared namespace prefix: 'dfs'.

I have tried changing the XPath to:
//my:myFields/my:FileInfo/my:FullPath
dfs:myFields/my:FileInfo/my:FullPath
my:myFields/my:FileInfo/my:FullPath
//myFields/my:FileInfo/my:FullPath
Many variations of the above

I still get an undeclared namespace prefix: 'x' on the ones with namespaces
in the name, and I get a null value for the XPaths that do not have any
namespace specified.

You probably deleted the generated code that sets the
SelectionNamespaces to your namespaces. Add this near the top of your
script, substituting your namespace in the place of the last one.

// The following line is created by Microsoft Office InfoPath to
define the prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2003-05-13T06:30:45"');
// said:
I would LOVE to do this in VBScript, but then I would have to recreate the
form from scratch (for the 10 millionth time) in order for it to get rid of
the JScript reference in the form (unless someone knows a way I can get
VBScript without rebuilding the form).

<URL:
http://groups.google.com/groups?th=ee64520bede56ebb&[email protected]#link5
/>

Regards,
Steve
 
B

Brad Simon

Thanks, this did help. I couldn't get the JScript to work, but I am sure it
was the code you gave me, since I had removed that at one point, trying to
get rid of the JScript code.

I ended up following the directions on the link you included at the bottom
of your post that showed me how to get rid of the JScript reference. It is
now working.
 

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