Error When Trying to Validate an XML File Against an XSD Schema AND using a Variable as SourceType
I get these error messages when specifying the SourceType: Variable and Source: User::PartsFileName inside the XML Task Editor, which I'm using OperationType: Validate to see if the XML file is written correctly according to the desired schema. [XML Task] Error: An error occurred with the following error message: "Data at the root level is invalid. Line 1, position 1.". [XML Task] Error: Property "New Source" has no source Xml text; Xml Text is either invalid, null or empty string.Evan Johnson
August 12th, 2011 8:44am

Can you check if the XML file properly formed? Can you post the first few liines from the XML file?Happy to help! Thanks. Regards and good Wishes, Deepak. In a revamp of my Blog!
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2011 9:26am

I'm positive the XML file is correct. I have been pointing to 1 XML file directly using FileConnection as the SourceType. Then I could test my XML Task - Validate XML AGAINST XSD was working correctly. I did this to continue on with my project, however, for what I need to accomplish, I need to read XML files from a variable. It's actually working already, but only grabbing 1 XML. I believe my problem lies in the ForEach loop. My XML Task is within the ForEach loop, but it's not cycling thru the Parts directory and grabbing all XMLs, just one. Evan Johnson
August 12th, 2011 9:42am

"I need to read XML files from a variable". Are you looping through XML files in a directory whose value is stored in a variable ? Which enumerator are you using in for each loop? If it is for each file enumertaor , there is a need to change the file connection to XML taks on the fly or runtime which can be done through the expressions or script.Happy to help! Thanks. Regards and good Wishes, Deepak. In a revamp of my Blog!
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2011 9:53am

I think my problem lies within the ForEach loop Editor under the tab Collection. Maybe something other than Foreach File Enumerator is what I need?Evan Johnson
August 12th, 2011 9:54am

1) If going by the literal meaning of "I need to read XML files from a variable", For each from variable enumerator is the one to be used.Happy to help! Thanks. Regards and good Wishes, Deepak. In a revamp of my Blog!
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2011 9:59am

hi, You say that your foreach loop always takes the same XML file ? What have you entered, in the tab Collection, in "Configuration" area, in "Files" ? Have you entered something like '*.xml' ?
August 12th, 2011 11:47am

My ForEach loop is always grabbing the top file in my networked source directory. Yes, by using the Foreach File Enumerator I search Files: *_parts.xml Folder: \\ddrftp\c$\ddr\JNJ\DDR\Parts file1_parts.xml file2_parts.xml file3_parts.xml When I tried Foreach From Variable Enumerator and put Variable PartsFileName. I get the error "Error: ForEach Variable Mapping number 1 to variable "User::PartsFileName" cannot be applied." I think the Variable's Value is suppose to be blank and not mapped to \\ddrftp\c$\ddr\JNJ\DDR\PartsEvan Johnson
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2011 2:44pm

And in the varaible mappings there is a vairable mapped with index 0 to retrieve the entire file path? This is for For each file enumerator. Happy to help! Thanks. Regards and good Wishes, Deepak. In a revamp of my Blog!
August 12th, 2011 3:26pm

Yes, exactly! Let me add that this program was giving to me from my manager. He had his source variables working on his machine. Now he has transferred me the intergration.dtsx file and I created my own project. That's how I acquired the problem. Evan Johnson
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2011 3:49pm

Great thought, but didn't cure the problem! I tried adding the \ and still the Foreeach loop is only grabbing one file from the networked directory. I'm not really sure how to use the breakpoint to see the value of my PartsFileName variable. I tried "Break when the container receives the OnVariableValueChanged event", but nothing popped up when rerunning the program. Folder: \\ddrftp\c$\ddr\JNJ\DDR\Parts\ Evan Johnson
August 12th, 2011 5:02pm

Did you try to add breakpoints to see the value of your variable at each iteration ? Try to add "\" at the end of you folder path : Folder: \\ddrftp\c$\ddr\JNJ\DDR\Parts\
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2011 4:55am

This is how the for each loop is configured which was successful in retrieving the required file names at my end:Happy to help! Thanks. Regards and good Wishes, Deepak. In a revamp of my Blog!
August 13th, 2011 3:18pm

Great thought, but didn't cure the problem! I tried adding the \ and still the Foreeach loop is only grabbing one file from the networked directory. I'm not really sure how to use the breakpoint to see the value of my PartsFileName variable. I tried "Break when the container receives the OnVariableValueChanged event", but nothing popped up when rerunning the program. Folder: \\ddrftp\c$\ddr\JNJ\DDR\Parts\ Evan Johnson You can add a breakpoint, in you foreach loop container, by pressing "F9" (if I remember well) on a component. For instance, click on your XML task and then press F9, a red circle appears on the task, that means there is a breakpoint. When you run your package you will be able to see the value of you variable "PartsFileName' (at the bottom left corner you can navigate within the package's variables to see their value) I hope it is clear for you, I wish I can make a screenshot but I am at home :(
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2011 7:29am

I found out my problem was that MaxErrorCount was set to 1 for the Foreach loop container and tasks inside. I was only grabbing 1 xml fle, when I was looking to process all xml files. Once I changed MaxErrorCount to 0, meaning ignore count of error and process until done, my Foreach loop could then grab everything. I didn't know that neat little fact. So really I not going to use SourceType: Variable, but instead File Connection for XML Task - Validate xml against xsd. @KiaraFR I don't have the option for Local Variables under Debug>Windows>Local Variables. I see the 'Local' option though. I'm using Visual Studio 2008 Pro Ed. thx!! Evan Johnson
August 20th, 2011 8:22am

Here is a screenshot that may help you : I am not sure that the MawErrorCount property is the solution... Maybe I am wrong but you have just told your package to ignore errors, it does not solve the problem :( I was only grabbing 1 xml fle, when I was looking to process all xml files. [...] So really I not going to use SourceType: Variable, but instead File Connection for XML Task - Validate xml against xsd Finally you do not need a foreach loop ? Perhaps you do not have time and/or tools, but you should make a simple package containing a foreach loop on a few files to understand properly how it works. I kow that sometimes it can be hard to understand something when you have only an achieved package...
Free Windows Admin Tool Kit Click here and download it now
August 20th, 2011 10:25am

I see our applications are different (other than language) I get the message "The key combination (Ctrl+Alt+V) is not a command. Why wouldn't I need a foreach loop? How else would the package grab all *_contracts.xml found in different directories without the loop? The thing is if an xml file is bad, it drops into my desktop folder BadFiles and continue processing other xml files without the For loop failing on the next iteration. That happens because XML Task found an error, but handled it by redirecting the file to desktop folder BadFiles. The Foreach loop still sees it as 1 error. If my records are already in my database, record rows drop into my excel sheet. thx!Evan Johnson
August 20th, 2011 10:35am

I I put a breakpoint on the Foreach Part loop, XML Task – Validate XML against XSD, and File System Task – Move Bad Part XML Files to Desktop Folder. I press play and the yellow arrow stops on Foreach Part loop first. In the Progress tab, no warnings/errors appear yet. Then I press play again and the Foreach Part loop header turns yellow and the yellow arrow moves to my second breakpoint (XML Task – Validate XML against XSD) and still no warnings/errors. I press play again and the yellow arrow moves to File System Task – Move Bad Part XML Files to Desktop Folder. That’s when XML Task – Validate XML against XSD turns red and I get the errors: [XML Task] Error: An error occurred with the following error message: "Data at the root level is invalid. Line 1, position 1." [XML Task] Error: Property "New Source" has no source Xml text; Xml Text is either invalid, null or empty string. Task XML Task - Validate XML against XSD failed This problem is related to the XML Task, where inside says SourceType: Variable, Source: User::PartsFileName. Please keep in mind, my boss transferred me this project. He created these user variables. The value of variable PartsFileName is mapped to the networked path where my xml files lye. I’m going to recreating the variable to see if that makes any difference. Also I could not see where the value of my variable is shown while stopped at a breakpoint. Evan Johnson
Free Windows Admin Tool Kit Click here and download it now
August 20th, 2011 12:56pm

You can see the value of your variable, while debugging, by clicking "Debug > Windows > Local Variables" (I have SSIS 2008 and in French but I think you can find the same structure ?). Now deactivate your XML task (the one that fails) and run your package again. Could you tell us the value of your variable PartsFileName at each iteration ?
August 21st, 2011 5:00am

No, I'm not using a variable as the sourceType anymore for my Foreach loop. I got my package to run! Thx, I'll let you guys know more when I get back to working on it. Evan Johnson
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2011 12:10pm

Hello, I am sorry that I have not answered sooner (too much work)... I get the message "The key combination (Ctrl+Alt+V) is not a command. It is (Ctrl+Alt+V+L) actually... Why wouldn't I need a foreach loop? How else would the package grab all *_contracts.xml found in different directories without the loop? I think I did not understand properly what you were meaning by : So really I not going to use SourceType: Variable, but instead File Connection for XML Task - Validate xml against xsd. Actually you are still using a variable, but for the flat file connection, right ? Finally, did you manage to run your package successfully ?
August 28th, 2011 6:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics