Liquid XML Data Binder 2020
Liquid XML Objects (C#, Visual Basic .Net) / Code Generation / Customizing the generated code with Override Values
In This Topic
    Customizing the generated code with Override Values
    In This Topic

    It is possible to modify some of the values in teh generated code on a per class or property basis. This allows class/property names to be changed individually, and some additional information to be provided that improves the usability or fidelity of the resulting library. These 'Override Values' can be specified in 2 ways.

    Attributing the source XSD

    Custom attributes can be added to the XSD to provide additional information to the LXO code generator, for example

    Example Title
    Copy Code
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:lxo="http://www.liquid-technologies.com/xml-objects/schema-markup"
    ...
        <xsd:element name="amount" type="xsd:decimal" lxo:name="NetTotal" lxo:numericPattern="0.00">
        
    

    All attributes must be in the namespace http://www.liquid-technologies.com/xml-objects/schema-markup.

    Attribute Allowable Parents Description
    name xs:attribute
    xs:alternative
    xs:complexType
    xs:element
    xs:simpleType

    Sets the name of the property/class that is generated.

    Note: it is still possible that the name will be modified by the generator in order to avoid duplicates and to ensure it is a valid identifier in the target output language.

    numericPattern

    xs:attribute
    xs:alternative
    xs:element
    xs:simpleType

    Where the value described is a numeric type


     

    Sets the formatting rules applied to numeric values when they are written out as XML.

    For example the value 24 in the element 'amount' would normally be rendered as <amount>24</amount>, however if the numericPattern="0.00" then the result would be <amount>24.00</amount>.

    The formatting rules can be found here Standard Numeric Format Strings and Custom Numeric Format Strings.

    See limitations for xs:decimal type below

     Configuration Files

    If it is not possible to desirable to change the source XSD files then configuration files can be placed alongside the source XSD's in 'caddy' files.

    The caddy file must have the same name as the XSD with the extension .lxocfg.

    For example if our schema file was called Accounts.xsd, then our configuration file may look like this

    Accounts.xsd.lxocfg
    Copy Code
    <?xml version="1.0" encoding="utf-8"?>
    <SchemaOverride xmlns='http://www.liquid-technologies.com/xml-objects/schema-markup'>
      <Item path='[complexType:invoice]/[element:amount]'>
        <Value name='name'>NetTotal</Value>
        <Value name='numericPattern'>0.00</Value>
      </Item>
    </SchemaOverride>
    

    If the schema set contains multiple XSD files then a configuration file is required for each file that you wish to override values in.

    How do I know what the 'path' value should be?

    If you run the application from the command line and add the verbose flag then it will write to the console all the .lxocfg files containing all the possible values that can be overridden.

    These are designed to be a guide to what can be changed (only include the values you want to change in the .lxocfg files you create).

     

    Using 'numericPattern' constraints on xs:deciamal types

    If you place a numericPattern onto an xs:decimal value, then this limits the range that the value it can contain, to that of the .Net Framework System.Decimal type (this is a huge range and suitable for most applications, but is not the unbounded range of the underlying BigDecimal type), the reason for this is that the value is converted to a System.Decimal in order to apply the formatting pattern, if the value is to large to fit into a System.Decimal an OverflowException will be raised.