Whitespace is not allowed at this location: IP 2003 - InfoPath Dev
in

InfoPath Dev

Whitespace is not allowed at this location: IP 2003

Last post 02-17-2009 07:12 AM by Jimmy. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 02-12-2009 06:49 PM

    Whitespace is not allowed at this location: IP 2003

    Hello,

    Can someone direct me in a fix for this?  I am getting this error when I click a button with code. 

    The error:

    "The following error occurred:

    Whitespace is not allowed at this location.

    File:script.js

    Line:99"

    The jscript code behind the button works most of the time, but the above error also occurs sometimes for certain records that the button is supposed to retrieve data for from a secondary data source.  I have done some testing and research on this and haven't had much luck.  Any ideas on how to identify where these whitespaces are coming from and how I can use perhaps the normalize-space function? Is this even a problem I can fix in IP or am I going to have to resolve it from within SQL server? 

    Basically, how would I go about trimming text to make sure that whitespaces are removed either in my current jscript code setup or by using the normalize-space function via rules.

    JIMMY, if are reading this, this is the jscript code you were helping with a little while ago.  It works most of the times, but I need to be able to have it work all the time.  What are your thoughts on these whitespaces?

    Thanks to anyone who can help on this matter.

    IP 2003

  • 02-12-2009 07:50 PM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    Hello again.

     Sorry the code isn't working so well for you.  Could you paste here some of the code before and after line 99 and specifically indicate which line is 99?

     Thanks.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-13-2009 02:47 AM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    Jimmy,

    It works most of the time like I said.  It is very helpful. Here is the code as it stands now.  I was trying to remove anything that I thought might be the cause so there are less blank lines in the code. With that said, the error line is at LINE: 87 and not 99 which was the line I had said in the orginial post. 

     

    Here is LINE: 87

              dataFields.appendChild(CreateNode(nodeString));

  • 02-13-2009 07:14 PM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    I see.  It looks like this is happening when you have a DB field with an ampersand in it.  I'm working on an improved version of this code that won't have that problem and will put it up here in a day or so.

     Jimmy

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-13-2009 09:15 PM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    I appreciate it Jimmy.  I assume that when you say "It looks like this is happening when you have a DB field with an ampersand in it.", sometimes the values in one of the fields that I am pulling from SQL have "&" in it.  If this is the case, then yes, it would not surprise me that some of the fields values in the SQL table use the "&".  I will research again knowing what u think might be the issue. I appreciate it Jimmy.

    Will you be modify line 87 or another line?

  • 02-13-2009 09:24 PM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    Wow, you are right on the "&". All the ones that I just tested have "&" in the fields.  How did you know by looking at the code that it was this character that was the issue?  Also, are there any other characters that u know might cause this type of an error? 

  • 02-15-2009 11:07 PM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    Googling on the "Whitespace is not allowed at this location" error showed that it was occurring when people had an ampersand by itself in XML.  I imagine an unpleasant error also would have happened if any of your DB fields had contained left angle brackets <.  In general it is not a good idea to create XML using string concatenation like I was doing, but as I don't do much InfoPath programming in JScript, I had been unable to think of a better method at the time.

    I have updated the code in my original post:

    http://www.infopathdev.com/forums/p/9471/36486.aspx#36486

    and it should not suffer from either of those limitations.  The main differences between the new code and what you have now are:

    • the columnNames array is no longer needed and has been removed.
    • The contents of the for-loop have changed entirely except for the first line.
    • The CreateNode() function is no longer needed and has been removed.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-16-2009 06:13 AM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

     Jimmy,

    First thanks for taking the time on this.  I used the new code after I made my changes, but now some errors come up.  The first one is on line 43.

    The query cannot be run for the following DataObject: x
    InfoPath cannot run the specified query.
    [0x80040E14][Microsoft OLE DB Provider for SQL Server] Invalid column name 'ID'.
    File:script.js
    Line:43

    Line: dc.Command = "SELECT * FROM [x] WHERE [x] = '" + field1.text + "' OR [ID] = '" + field1.text + "'";

    I took a shot and used the old line from the first code you provided which is pretty much the same but without the last two parts

    dc.Command = "SELECT * FROM [x] WHERE [x] = '" + field1.text + "'";

    I  then was getting the below error after I used the line above in the code. 

    The specified varXmlToEdit value for the View.ExecuteAction call is not valid.
    File:script.js
    Line:81

    I haven't been able to get past this error. 

  • 02-16-2009 07:09 AM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    As the comments directly above it suggest, the "ResultRow_19" part of this line will be different in every form.  Please look at the properties of the repeating table to which you are copying the data and find the appropriate value for your form:

    XDocument.View.ExecuteAction("xCollection::insert", "ResultRow_19");

             

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-17-2009 06:20 AM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    Jimmy,

    I can't thank you enough for working with me on this.  It works nicely.  I think it you were closer, I would stop by and shake your hand.  Anyway, I have a lot of respect for you and everyone else in this forum that take the time to help users like myself while learning this product.  Thank you Jimmy.

  • 02-17-2009 07:12 AM In reply to

    Re: Whitespace is not allowed at this location: IP 2003

    Thank you for the very kind words.  I'm glad I was able to help you on your way and I'll be happy to help you again in the future.

     Jimmy

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.