Jump to content
Sign in to follow this  
iperryman

validating xml files

Recommended Posts

I am new to XML and new to IP-XACT, so please forgive me for this newbie question.

 

I want to create some IP-XACT from a tool. I want to ensure that this output is valid according to your schema.  I think the tool to use is xmllint.

 

So before I went and tried to write code that will generate IP-XACT XML, I tried to do validate the examples that are in the recent spec for IP-XACT  IEEE Std 1685-2014.

 

I downloaded the spec and extracted the first example from Annex I on pages 471- 473.  I saved the example in my home directory as "~/xml_fun/rtl_test.xml".  I have attached it below.

 

 

I then tried to use xmllint to validate the file:

 

xmllint --format --pretty 1 --load-trace --debug --schema "http://www.accellera.org/XMLSchema/IPXACT/2.0/index.xsd"~/xml_fun/rtl_test.xml

 

Which failed like this:

http://www.accellera.org/XMLSchema/IPXACT/2.0/index.xsd:92:parser error : Opening and ending tag mismatch: link line 46 and head
</head> 
       ^
http://www.accellera.org/XMLSchema/IPXACT/2.0/index.xsd:117:parser error : Opening and ending tag mismatch: img line 117 and a
ra.png" border="0" alt="Accellera Systems Initiative" class="img-responsive"></a
 

etc.

 

So I downloaded the xsd files from the web an stored them in a local folder (/tools/ip-xact/2014/XMLSchema).  I tried again:

xmllint --format --pretty 1 --load-trace --debug --schema /tools/ip-xact/2014/XMLschema/index.xsd ~/xml_fun/rtl_test.xml

 

This time the schema is loaded as far as I can tell:

 

Loaded URL="/tools/ip-xact/2014/XMLschema/index.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/busDefinition.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/identifier.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/simpleTypes.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/autoConfigure.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/xml.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/subInstances.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/commonStructures.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/port.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/constraints.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/signalDrivers.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/file.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/fileType.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/generator.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/component.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/busInterface.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/abstractionDefinition.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/memoryMap.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/model.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/design.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/designConfig.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/catalog.xsd" ID="(null)"
Loaded URL="/tools/ip-xact/2014/XMLschema/abstractor.xsd" ID="(null)"
Loaded URL="/home2/iperryman/xml_fun/rtl_test.xml" ID="(null)"
 

 

But it still fails:

 

/home2/iperryman/xml_fun/rtl_test.xml:8: element abstractionDefinition: Schemas validity error : Element '{http://www.accellera.org/XMLSchema/IPXACT/2.0}abstractionDefinition':No matching global declaration available for the validation root.
/home2/iperryman/xml_fun/rtl_test.xml fails to validate
 

Can you tell me if this is the expected method for validating code.  If so, then is there something wrong with the example in the spec, and if not, what is the normal way to validate that generated code conforms to the schema.

 

Thanks,

Ian

rtl_test.xml

Share this post


Link to post
Share on other sites

Hello iperryman,

First, Annex I is informative and not normative.

The schema namespace and location in the example should use 1685-2014 instead of 2.0. Consider this a bug in the document. I don't think the committee intended to release the 2.0 version of the schema. Regardless, 2.0 schema location doesn't work.

Second, the schema location attribute itself is incorrect.

Third, copying text out of a PDF file is not reliable. I had to fix the file I copying output document to get it to pass.

Parsing and generating IP-XACT files is quite complex. Please consider commercially available solutions.

Share this post


Link to post
Share on other sites

Thank you Richard 

 

With your feed back I was able to validate the file.

 

I understand that the section of the document is "informative".  However, I believe the spirit of the Annex is to provide a worked example. Perhaps the committee will find a  place to publish the examples (and corrections to them).  

 

I have attached the "repaired" version of the file which does validate for anyone else who happens to fall down this rabbit hole.

 

Best regards,

Ian

rtl_test.xml

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×