LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Validate XML to xsd schema

Solved!
Go to solution

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?





Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
Download All
0 Kudos
Message 1 of 4
(4,552 Views)

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. 

National Instruments
0 Kudos
Message 2 of 4
(4,491 Views)
Solution
Accepted by topic author crelf

Yep, it works.

XMLschema.PNG

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.

 

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 3 of 4
(4,479 Views)

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.





Copyright © 2004-2023 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 4 of 4
(4,440 Views)