[ 
https://issues.apache.org/jira/browse/FELIX-3471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13777930#comment-13777930
 ] 

Matt Bishop commented on FELIX-3471:
------------------------------------

I think there is a bug in all the metatype XSDs, and particular in the metatype 
XSDs for v1.1.0 and 1.2.0. I am not sure where to file this bug, but I'll try 
here and see if it leads somewhere else.

Simply put, one cannot create validatable MetaData documents that validate 
using these XSDs. The problem is that the namespace defined in the schema is 
not applied to the child elements correctly. Their <xsd:schema> header elements 
are missing the all-important elementFormDefault="qualified" 
attributeFormDefault="unqualified" pair to allow elements below the MetaData to 
be "found" by the parser. 

This leads from bad, but validatable (1.0.0, notice how only the MetaData 
element gets a prefix? prefixing the OCD and other children fails):

<?xml version="1.0" encoding="UTF-8"?>
<metadata:MetaData
                xmlns:metadata="http://www.osgi.org/xmlns/metatype/v1.0.0";
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                xsi:schemaLocation="http://www.osgi.org/xmlns/metatype/v1.0.0 
http://www.osgi.org/xmlns/metatype/v1.0.0/metatype.xsd";>

        <OCD description="Configured Example Application" name="ConfigApp" 
id="ConfigApp">
                <AD name="Title" id="title" required="true" type="String" 
default="Default Title" description="Title for the Application"/>
        </OCD>

        <Designate pid="ConfigApp">
                <Object ocdref="ConfigApp"/>
        </Designate>
</metadata:MetaData>



To unvalidatable at all in 1.1.0 / 1.2.0:
<?xml version="1.0" encoding="UTF-8"?>
<metadata:MetaData
                xmlns:metadata="http://www.osgi.org/xmlns/metatype/v1.2.0";
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                xsi:schemaLocation="http://www.osgi.org/xmlns/metatype/v1.2.0 
http://www.osgi.org/xmlns/metatype/v1.2.0/metatype.xsd";>

        <OCD description="Configured Example Application" name="ConfigApp" 
id="ConfigApp">
                <AD name="Title" id="title" required="true" type="String" 
default="Default Title" description="Title for the Application"/>
        </OCD>

        <Designate pid="ConfigApp">
                <Object ocdref="ConfigApp"/>
        </Designate>
</metadata:MetaData>


Also fails if you remove the metadata: prefix.


<?xml version="1.0" encoding="UTF-8"?>
<metadata:MetaData
                xmlns:metadata="http://www.osgi.org/xmlns/metatype/v1.2.0";
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                xsi:schemaLocation="http://www.osgi.org/xmlns/metatype/v1.2.0 
http://www.osgi.org/xmlns/metatype/v1.2.0/metatype.xsd";>

        <metadata:OCD description="Configured Example Application" 
name="ConfigApp" id="ConfigApp">
                <metadata:AD name="Title" id="title" required="true" 
type="String" default="Default Title" description="Title for the Application"/>
        </metadata:OCD>

        <metadata:Designate pid="ConfigApp">
                <metadata:Object ocdref="ConfigApp"/>
        </metadata:Designate>
</metadata:MetaData>

Validation error: 
cvc-complex-type.2.4.a: Invalid content was found starting with element 
'metadata:OCD'. One of '{OCD, Designate, 
WC[##other:"http://www.osgi.org/xmlns/metatype/v1.2.0"]}' is expected.


Taking out the prefix also fails. In short there is no clear way to use the 
1.1.0 and 1.2.0 XSDs for their stated purpose of tools-driven document 
validation.

                
> Support Schema validation for MetaData XML documents
> ----------------------------------------------------
>
>                 Key: FELIX-3471
>                 URL: https://issues.apache.org/jira/browse/FELIX-3471
>             Project: Felix
>          Issue Type: Bug
>          Components: Metatype Service
>    Affects Versions: metatype-1.0.4
>            Reporter: Alexandre Castro Alves
>
> MetaData XML documents are not being W3C Schema-validated.
> Provide option for doing so.
> Thanks
> Alex

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to