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 the 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=""
        <xsd:element name="amount" type="xsd:decimal" lxo:name="NetTotal" lxo:numericPattern="0.00">

    All attributes must be in the namespace

    Attribute Allowable Parents Description
    name xs:attribute

    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.



    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/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

    Copy Code
    <?xml version="1.0" encoding="utf-8"?>
    <SchemaOverride xmlns=''>
      <Item path='[complexType:invoice]/[element:amount]'>
        <Value name='name'>NetTotal</Value>
        <Value name='numericPattern'>0.00</Value>

    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 command line application 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:decimal types

    If you place a numericPattern onto an xs:decimal value, this will limit the range of values that 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 too large to fit into a System.Decimal an OverflowException will be raised.