cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How change enumCodeType Pattern in Item.xsd file?

Former Member
0 Kudos
1,214

I have created an enumtype in the Item.xml file, like this:

     <enumtype generate="true" code="ColcilEnum" autocreate="true" dynamic="true">
         <value code="V"/>
         <value code="01"/>
                     <value code="N/A"/>
                     <value code="4X6"/>
     </enumtype>

But it gives the following error:

"cvc-pattern-valid: Value 'N/A' is not facet-valid with respect to pattern ([a-zA-Z_])+([a-z_A-Z$0-9])*."

I tried to change the item.xsd file, but when execute ant clean all comand, the file return to original code:

           <xs:simpleType name="enumCodeType">
                          <xs:annotation>
                                        <xs:documentation>Configures the code of an enumeration value element. 
                                         Must start with a letter or underscore.</xs:documentation>
                          </xs:annotation>
                          <xs:restriction base="xs:normalizedString" >
                                        <xs:pattern value="([a-zA-Z_])+([a-z_A-Z$0-9])*"/>
                          </xs:restriction>
           </xs:simpleType>
 

Is there any way to change this pattern?.

Thanks, Regards, Aldo

View Entire Topic
arvind-kumar_avinash
Active Contributor
0 Kudos

Hi

The reason why the changed code in the items.xsd file of your extension returned to the original code is the following code in platform/resources/ant/antmacros.xml

 <foreachext>
     <do>
         <property name="@{extname}.items.xml" location="${ext.@{extname}.path}/resources/@{extname}-items.xml" />
         <if>
             <available file="${@{extname}.items.xml}" />
             <then>
                 <copy todir="${ext.@{extname}.path}/resources" file="${platformhome}/resources/schemas/items.xsd" failonerror="false" />
                 <yvalidatexml id="@{extname}" source="${@{extname}.items.xml}" schema="${platformhome}/resources/schemas/items.xsd" />
             </then>
         </if>
     </do>
 </foreachext>

So, if you want to change something in items.xsd, you need to change the platform/resources/schemas/items.xsd file and the same will be reflected in the items.xsd of all extensions, including yours, after a build. However, it is not recommended to make any changes in this file.

Now, coming to the values you have in your enum, the following values are invalid:

 <value code="01"/>
 <value code="N/A"/>
 <value code="4X6"/>

Please note that enum constants must be valid Java identifiers.

You need to use valid value codes (enum constants) in the enum and if you want to change the way, they should be displayed, you can use localized names for the codes in the properties files (e.g. refer https://wiki.hybris.com/pages/viewpage.action?pageId=294094110)