简体   繁体   中英

How can I set a max length for a string value in a XML file?

I'm trying to modify this XML that was generated by a Toolkit software. I need to set a max length for a value (string) in this file.

I tried to use the MaxLength="10" property and lenght="10" . They didn't work:(

<?xml version="1.0" encoding="UTF-8"?>
<report>
    <name>REPORT</name>
    <description>Elenco Pratiche</description>
    <engine format="XLS" name="BIRT">
        <template>REPORT.rptdesign</template>
    </engine>
    <onlinePage/>
    <PARAS>
        <name dataType="String" displayName="Business Unit"
            displayType="text-box" inputdefault="SYS_BU_CODE" property="P">ISP_BUSI_UNIT</name>
        <name dataType="String" displayName="UO Pratica"
            displayType="text-box" inputdefault="" length="8" property="O">C_UNIT_CODE</name>
        <name FCRule="GTEE_TYPE_IMPEGNO" dataType="String" displayName="Tipo Impegno"
            displayType="list-box" inputdefault="" isSingle="true" property="O">GTEE_TYPE_IMPEGNO</name>
    </PARAS>
    <MAIL_RULE/>
</report>

I need to set this max length for the field "C_UNIT_CODE". Can someone help me?

You need a XML-Schema-Definition (XSD). Then you create a simpleType and set the maxLength

<xs:simpleType name="C_UNIT_CODE">
    <xs:restriction base="xs:string">
       <xs:maxLength value="12"/>
    </xs:restriction>
</xs:simpleType>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM