04-14-2012 01:21 PM
The "Load XML String.vi" help suggest that "In the LabVIEW parser, the external vocabulary can be a Document Type Definition (DTD) or a schema.", but does anyone know if the last part is true? I'm trying to validate against an xsd (it's called out in the XML file), and the intial element that contains the reference to the xsd is reported as inconsistant, which suggests to me that the validator doesn't even get to where the schema is defined before it throws that element out.
http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/parsing_xml_files_in_lv/
For example - if my XML file and xsd schema look something like the ones I've attached, "Load from String.vi" gives me the following parsing error:
Line 2, Column 11, Message: Unknown element 'PDEF_data'
Line 2, Column 95, Message: Attribute 'xmlns:xsi' is not declared for element 'PDEF_data'
Line 2, Column 169, Message: Attribute 'xsi:noNamespaceSchemaLocation' is not declared for element 'PDEF_data'
Line 4, Column 16, Message: Unknown element 'MillingOffset'
As you can see, it looks like it starts validating before it finds the schema location - anyone got any ideas?
Solved! Go to Solution.
04-16-2012 05:45 PM
crelf,
The VI should be able to able to reference a schema as stated in the help file. Are you setting the appropriate boolean parameters with the load VI such that it is set to process a schema instead of the default? Namely the 'process schema' and 'process namespaces' booleans needing to be set to True.
If you would like to post your code I can look it over and try some things on my end with your files?
Regards,
Chris D.
04-17-2012 12:17 AM
Yep, it works.
Make sure your SchemaLocation is pointing to the correct file.
In the example you posted the filename doesn't match the definition in the XML file.
I.e. xml file defines the schema definition filename as PDEF.xsd but the name of the xsd you attached is XMLSchema.xsd.
05-01-2012 09:02 AM
Thanks guys, after a long time away from this, I tried again and now it all looks fine. Not sure what I was doing wrong, but thanks a lot for your support.