Page 1 of 1

Content-Completion can't work in some situation, when using master file.

Posted: Fri Feb 16, 2018 6:38 pm
by serioadamo97
In order to describe this question, let me give two examples:

First example:
I write the following xsd:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="Table"> </xs:complexType>
<xs:complexType name="TableA">
<xs:complexContent>
<xs:extension base="Table">
<xs:all>
<xs:element maxOccurs="unbounded" minOccurs="0" name="A-Record-1">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyA1"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="A-Record-2">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyA1"/>
<xs:element name="PropertyA2"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TableB">
<xs:complexContent>
<xs:extension base="Table">
<xs:all>
<xs:element name="B-Record-1" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB1"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="B-Record-2" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB2"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="B-Record-3" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB3"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="TestDB5">
<xs:complexType>
<xs:all>
<xs:element maxOccurs="1" minOccurs="1" name="TableContainerA">
<xs:complexType>
<xs:sequence>
<xs:element name="Table" type="TableA"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="TableContainerB">
<xs:complexType>
<xs:sequence>
<xs:element name="Table" type="TableB"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Then I create xml instance which using xi:include to modular them, the xml instance file be splited to 3 files:
test-db-5.xml (which be set to master file):

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<TestDB5 xmlns:xi="http://www.w3.org/2001/XInclude">
<TableContainerA>
<xi:include href="tableA.xml"/>
</TableContainerA>
<TableContainerB>
<xi:include href="tableB.xml"/>
</TableContainerB>
</TestDB5>
tableA.xml:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<Table>
<A-Record-1 name="name0">
<PropertyA1>
</PropertyA1>
</A-Record-1>
<A-Record-2 name="name2">
<PropertyA1>
</PropertyA1>
<PropertyA2>
</PropertyA2>
</A-Record-2>
</Table>
tableB.xml:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<Table>
<B-Record-1 name="name6">
<PropertyB1>
</PropertyB1>
</B-Record-1>
<B-Record-2 name="name8">
<PropertyB2>
</PropertyB2>
</B-Record-2>
</Table>
My question is:
Why these 3 files can be validated successfully, but the Content-Completion can't work in tableA and tableB?
(Maybe have some element proposal, but they are in cache, not collect from XSD, press F5 to clean them.)

Second example:
I write the following xsd:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="Table"> </xs:complexType>
<xs:complexType name="TableA">
<xs:complexContent>
<xs:extension base="Table">
<xs:all>
<xs:element maxOccurs="unbounded" minOccurs="0" name="A-Record-1">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyA1"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="A-Record-2">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyA1"/>
<xs:element name="PropertyA2"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TableB">
<xs:complexContent>
<xs:extension base="Table">
<xs:all>
<xs:element name="B-Record-1" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB1"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="B-Record-2" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB2"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="B-Record-3" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB3"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="Table" type="Table">
<xs:alternative type="TableA" test="@kind = 'A'"/>
<xs:alternative type="TableB" test="@kind = 'B'"/>
</xs:element>
<xs:element name="TestDB4">
<xs:complexType>
<xs:all>
<xs:element maxOccurs="unbounded" minOccurs="0" name="TableContainer">
<xs:complexType>
<xs:sequence>
<xs:element ref="Table" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute inheritable="true" name="kind"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Then I create xml instance which using xi:include to modular them, the xml instance file be splited to 3 files:
test-db-4.xml (which be set to master file):

Code: Select all


<TestDB4 xmlns:xi="http://www.w3.org/2001/XInclude">
<TableContainer kind="A">
<xi:include href="tableA.xml"/>
</TableContainer>
<TableContainer kind="B">
<xi:include href="tableB.xml"/>
</TableContainer>
</TestDB4>
tableA.xml:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<Table>
<A-Record-1 name="name0">
<PropertyA1>
</PropertyA1>
</A-Record-1>
<A-Record-2 name="name2">
<PropertyA1>
</PropertyA1>
<PropertyA2>
</PropertyA2>
</A-Record-2>
</Table>
tableB.xml:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<Table>
<B-Record-1 name="name6">
<PropertyB1>
</PropertyB1>
</B-Record-1>
<B-Record-2 name="name8">
<PropertyB2>
</PropertyB2>
</B-Record-2>
<B-Record-3 name="name10">
<PropertyB3>
</PropertyB3>
</B-Record-3>
</Table>
The major difference between the first example and second example is: The second example has a global element for Table and use type alternatives + inheritable attribute to determin Type.

My question is:
Why these 3 files can be validated successfully, but the Content-Completion can't work in tableA and tableB?
(Maybe have some element proposal, but they are in cache, not collect from XSD, press F5 to clean them.)

Is this strange behavior in line with expectations of master file?
I said the behavior is strange becuase it can validate successful, but Content-Completion is not synchronized.
(PS: I try to use framework and write some elementProposals in cc_config.xml which satisfy XSD, but the result is the same.)
Thanks.

Re: Content-Completion can't work in some situation, when using master file.

Posted: Tue Feb 20, 2018 11:46 am
by tavy
Hello,

For the first example the content completion does not work for your modules because the schema does not define a global "Table" element.
For the second example you define a global "Table" element in your schema, but its type is based on an inheritable attribute "@kind" that is added in the main file. The content completion can look only in the current file in order to determine the element type. Therefore, you need to change you schema and define the "@kind" on the "Table" element instead of adding it on the "TableContainer". Something like this:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">
<xs:complexType name="Table">
<xs:attribute name="kind"/>
</xs:complexType>
<xs:complexType name="TableA">
<xs:complexContent>
<xs:extension base="Table">
<xs:all>
<xs:element maxOccurs="unbounded" minOccurs="0" name="A-Record-1">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyA1"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="A-Record-2">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyA1"/>
<xs:element name="PropertyA2"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TableB">
<xs:complexContent>
<xs:extension base="Table">
<xs:all>
<xs:element name="B-Record-1" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB1"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="B-Record-2" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB2"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="B-Record-3" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="PropertyB3"/>
</xs:sequence>
<xs:attribute name="name"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="Table" type="Table">
<xs:alternative type="TableA" test="@kind = 'A'"/>
<xs:alternative type="TableB" test="@kind = 'B'"/>
</xs:element>
<xs:element name="TestDB4">
<xs:complexType>
<xs:all>
<xs:element maxOccurs="unbounded" minOccurs="0" name="TableContainer">
<xs:complexType>
<xs:sequence>
<xs:element ref="Table" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

Code: Select all


<Table kind="A">
<A-Record-1 name="name0">
<PropertyA1>
</PropertyA1>
</A-Record-1>
<A-Record-2 name="name2">
<PropertyA1>
</PropertyA1>
<PropertyA2>
</PropertyA2>
</A-Record-2>
</Table>
Best Regards,
Octavian