Skip to main content
added 6 characters in body
Source Link

I have designed my XML Schema using the above rules. I have used "assert" to validate the XML file. I have used every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)]) and

every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)])

and also tried using entity instead of * every $x in .//entity satisfies empty($x//entity[node-name(.) = node- name($x)])

every $x in .//entity satisfies empty($x//entity[node-name(.) = node- name($x)])
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="file:/M:/axm.xsd" name="name0">

 <aspect name="scenarioDec">
  <entity name="Environment">
   <multiAspect name="entityMAsp">
    <!-- <entity name="EntityTest"></entity>  --> <!-- if i add "EntityTest" 
as an entity then it shows error but it should be correct -->
   </multiAspect>
  </entity>

 </aspect>
 


</entity>

Inside "multiAspect" when I tried to add the below line it shows error.

<entity name="EntityTest">

But it should be correct.

I have designed my XML Schema using the above rules. I have used "assert" to validate the XML file. I have used every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)]) and also tried using entity instead of * every $x in .//entity satisfies empty($x//entity[node-name(.) = node- name($x)])

<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="file:/M:/axm.xsd" name="name0">

 <aspect name="scenarioDec">
  <entity name="Environment">
   <multiAspect name="entityMAsp">
    <!-- <entity name="EntityTest"></entity>  --> <!-- if i add "EntityTest" 
as an entity then it shows error but it should be correct -->
   </multiAspect>
  </entity>

 </aspect>
 


</entity>

I have designed my XML Schema using the above rules. I have used "assert" to validate the XML file. I have used

every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)])

and also tried using entity instead of *

every $x in .//entity satisfies empty($x//entity[node-name(.) = node- name($x)])
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="file:/M:/axm.xsd" name="name0">

 <aspect name="scenarioDec">
  <entity name="Environment">
   <multiAspect name="entityMAsp">
    <!-- <entity name="EntityTest"></entity>  --> <!-- if i add "EntityTest" 
as an entity then it shows error but it should be correct -->
   </multiAspect>
  </entity>

 </aspect>


</entity>

Inside "multiAspect" when I tried to add the below line it shows error.

<entity name="EntityTest">

But it should be correct.

added 1338 characters in body
Source Link
<?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="aspectType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>

<xs:complexType name="multiAspectType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>

<xs:complexType name="specializationType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>


<xs:complexType name="varType"> <!--  mixed="true" -->
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>


<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
            </xs:choice>                
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
    </xs:complexType>

    <xs:unique name="entityunqall">
     assert test="every $x <xs:selectorin xpath="*./entity"/>        * satisfies empty($x//*[node-name(.) = node-name($x)])"/>
        <xs:field xpath="@name"/>
    </xs:unique>     

    
    <xs:unique name="varunq">
        <xs:selector xpath="*/entity/var"/>            complexType>
        <xs:field xpath="@name"/>
    </xs:unique>

</xs:element>

<xs:element name="aspect" type="aspectType"/>
<xs:element name="multiAspect" type="multiAspectType"/>
<xs:element name="specialization" type="specializationType"/>
<xs:element name="var" type="varType"/>   

 
</xs:schema>
<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
                
            </xs:choice>            
            
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
        <xs:assert test="empty(../@name)"/>
         
        <!--                
            Your suggestion: 
                <xs:assert test="empty(../Entity2)"/>
            but for my case may be it will be  
            <xs:assert test="empty(../@name)"/>
            
            as entity name is not fixed. I have tried both the way but it is not working. 
        -->
        
    </xs:complexType>

-----Edit 3-------

I have four types of node: 1. Entity, 2. MultiAspect, 3. Aspect and 4. Specialization. If the node is Entity then its successors are Aspect, MultiAspect or Specialization. If the type of a node is Aspect, MultiAspect or Specialization, then the type of its children are Entity. The root node is always Entity.

I have designed my XML Schema using the above rules. I have used "assert" to validate the XML file. I have used every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)]) and also tried using entity instead of * every $x in .//entity satisfies empty($x//entity[node-name(.) = node- name($x)])

But it is showing error all the time. XML Schema is given above.

<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="file:/M:/axm.xsd" name="name0">

 <aspect name="scenarioDec">
  <entity name="Environment">
   <multiAspect name="entityMAsp">
    <!-- <entity name="EntityTest"></entity>  --> <!-- if i add "EntityTest" 
as an entity then it shows error but it should be correct -->
   </multiAspect>
  </entity>

 </aspect>



</entity>
<?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="aspectType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>

<xs:complexType name="multiAspectType">
    <xs:sequence>
        <xs:element ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>

<xs:complexType name="specializationType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>


<xs:complexType name="varType"> <!--  mixed="true" -->
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>


<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
            </xs:choice>                
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
    </xs:complexType>

    <xs:unique name="entityunqall">
        <xs:selector xpath="*/entity"/>            
        <xs:field xpath="@name"/>
    </xs:unique>     

    
    <xs:unique name="varunq">
        <xs:selector xpath="*/entity/var"/>            
        <xs:field xpath="@name"/>
    </xs:unique>

</xs:element>

<xs:element name="aspect" type="aspectType"/>
<xs:element name="multiAspect" type="multiAspectType"/>
<xs:element name="specialization" type="specializationType"/>
<xs:element name="var" type="varType"/>   

 
</xs:schema>
<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
                
            </xs:choice>            
            
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
        <xs:assert test="empty(../@name)"/>
         
        <!--                
            Your suggestion: 
                <xs:assert test="empty(../Entity2)"/>
            but for my case may be it will be  
            <xs:assert test="empty(../@name)"/>
            
            as entity name is not fixed. I have tried both the way but it is not working. 
        -->
        
    </xs:complexType>
<?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="aspectType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>

<xs:complexType name="multiAspectType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>

<xs:complexType name="specializationType">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>


<xs:complexType name="varType"> <!--  mixed="true" -->
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="entity"/>
    </xs:sequence>
    <xs:attribute name="name" use="required"/>
</xs:complexType>


<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
            </xs:choice>                
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
<xs:assert test="every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)])"/>
        
    </xs:complexType>

    
</xs:element>

<xs:element name="aspect" type="aspectType"/>
<xs:element name="multiAspect" type="multiAspectType"/>
<xs:element name="specialization" type="specializationType"/>
<xs:element name="var" type="varType"/>   

 
</xs:schema>
<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
                
            </xs:choice>            
            
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
        <xs:assert test="empty(../@name)"/>
         
        <!--                
            Your suggestion: 
                <xs:assert test="empty(../Entity2)"/>
            but for my case may be it will be  
            <xs:assert test="empty(../@name)"/>
            
            as entity name is not fixed. I have tried both the way but it is not working. 
        -->
        
    </xs:complexType>

-----Edit 3-------

I have four types of node: 1. Entity, 2. MultiAspect, 3. Aspect and 4. Specialization. If the node is Entity then its successors are Aspect, MultiAspect or Specialization. If the type of a node is Aspect, MultiAspect or Specialization, then the type of its children are Entity. The root node is always Entity.

I have designed my XML Schema using the above rules. I have used "assert" to validate the XML file. I have used every $x in .//* satisfies empty($x//*[node-name(.) = node-name($x)]) and also tried using entity instead of * every $x in .//entity satisfies empty($x//entity[node-name(.) = node- name($x)])

But it is showing error all the time. XML Schema is given above.

<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="file:/M:/axm.xsd" name="name0">

 <aspect name="scenarioDec">
  <entity name="Environment">
   <multiAspect name="entityMAsp">
    <!-- <entity name="EntityTest"></entity>  --> <!-- if i add "EntityTest" 
as an entity then it shows error but it should be correct -->
   </multiAspect>
  </entity>

 </aspect>



</entity>
added syggestion
Source Link

........ Edit 2: ........

<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
                
            </xs:choice>            
            
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
        <xs:assert test="empty(../@name)"/>
         
        <!--                
            Your suggestion: 
                <xs:assert test="empty(../Entity2)"/>
            but for my case may be it will be  
            <xs:assert test="empty(../@name)"/>
            
            as entity name is not fixed. I have tried both the way but it is not working. 
        -->
        
    </xs:complexType>

........ Edit 2: ........

<xs:element name="entity">
    <xs:complexType>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="aspect"/>
                <xs:element ref="specialization"/>
                <xs:element ref="multiAspect"/>
                <xs:element ref="var"/>
                
            </xs:choice>            
            
        </xs:sequence>

        <xs:attribute name="name" use="required"/>
        
        <xs:assert test="empty(../@name)"/>
         
        <!--                
            Your suggestion: 
                <xs:assert test="empty(../Entity2)"/>
            but for my case may be it will be  
            <xs:assert test="empty(../@name)"/>
            
            as entity name is not fixed. I have tried both the way but it is not working. 
        -->
        
    </xs:complexType>
edited body
Source Link
Loading
deleted 4 characters in body
Source Link
Loading
added a picture to make my question more understandable.
Source Link
Loading
Source Link
Loading