1

So,

I am using a CMS platform to manage content, OpenCMS specifically but the question is generic.

Said platform uses XSD files to define its template elements and i18/message files to internationalize them.

I have achieved basic internationalization but I am stumped by my current problem.

In the following file

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>

<xsd:element name="PaginationDefaults" type="OpenCmsPaginationDefaults"/>

<xsd:complexType name="OpenCmsPaginationDefaults">
    <xsd:sequence>
        <xsd:element name="PaginationDefault" type="OpenCmsPaginationDefault" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="OpenCmsPaginationDefault">
    <xsd:sequence>
        <xsd:element name="ShowPagination" type="OpenCmsBoolean" />
        <xsd:element name="MaxItems" type="OpenCmsString" minOccurs="0" />
        <xsd:element name="ItemsPerPage" type="OpenCmsString" minOccurs="0" />
    </xsd:sequence>
    <xsd:attribute name="language" type="OpenCmsLocale" use="optional"/>
</xsd:complexType>

<xsd:annotation>
    <xsd:appinfo>
        <defaults/>
        <layouts/>
        <validationrules>
            <rule element="MaxItems" regex="\d+" message="${key.error.parse.number}" />
            <rule element="ItemsPerPage" regex="\d+" message="${key.error.parse.number}" />
        </validationrules>
    </xsd:appinfo>
</xsd:annotation>  
</xsd:schema>

I can define the value of any of the named properties with no issues from any template that incorporates a PaginationDefault.

This is as basic as typing

 label.PaginationDefault.property 

On the key field and giving it my desired message on the value field

I am stumpted however on accessing the value of key.error.parse.number. and any time there's an error I get ????key.error.parse.number????? on the screen which just doesn't look enticing for newer clients and underwhelms them.

I have full access to the XSD. I know I can hardcode a message on the error field but there should be a way of accessing it from the message files that is currently beyond me.

Please help me if you can.

Update looking into it there are some files where it works. Said files have the structure

 <rule element="ItemsPerPage" regex="\d+" message="${key.error.name}" />

If that is the case I can just put error.name as a key and assign it a value.

The issue comes with a nested XSD where no combination of error nameofnestedxsd and name of error works(tried just about every order of those words).

kjhughes
  • 106,133
  • 27
  • 181
  • 240
dot
  • 64
  • 7
  • XSD does not support variables in the way you seek, but see duplicate link for two alternative: XML entity references or XSLT reassembly of the XSD with substitutions made. – kjhughes Oct 27 '21 at 13:17
  • Found my solution. Nested files need to have their own messages file defined and the error needs to be defined insaid messages file. Once that happens the error translation gets propagated properly. A colleague was able to give me hand earlier and saw the issue after some trial an error. – dot Oct 28 '21 at 09:15
  • What you describe is not standard XSD functionality but rather the properties of some (unspecified) application using `xsd:appinfo`. – kjhughes Oct 28 '21 at 12:29
  • You are right. Just putting out there what helped me solve the issue in the end for anyone in a similar situation in the future. – dot Oct 29 '21 at 10:06
  • I am using OpenCMS xsd files as stated in the OP. – dot Nov 02 '21 at 10:46
  • Sorry, I retract the "(unspecified)" part of my earlier comment, but your answer's dependency to OpenCMS remains true: There is no standard XSD answer to your question; it's OpenCMS-bound. – kjhughes Nov 02 '21 at 11:37
  • I've re-opened your question with improved title and tagging so that future readers in a similar situation as yours might benefit. (For anyone interested in an answer apart from OpenCMS, see the previous [duplicate link](https://stackoverflow.com/q/34777149/290085), which provides limited but standard XML and XSLT options for variables in XML files.) – kjhughes Nov 02 '21 at 11:56

0 Answers0