28 Juli 2014

Include XML Schema Reference in XML to get IDE Code Completion

One thing that I find very often is the missing XML schema reference in XML files.
The advantage of including the reference is code completion in your IDE because with the xml schema the IDE knows about the structure of the XML document.

Example:
<?xml version="1.0" encoding="UTF-8"?>
<batch:job
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:batch='http://xmlns.jcp.org/xml/ns/javaee'
    xsi:schemaLocation='http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/jobXML_1_0.xsd'>

    <batch:step id="step1">
        <batch:chunk>
            <batch:reader ref="Reader" />
            <batch:processor ref="Processor" />
            <batch:writer ref="Writer" />
        </batch:chunk>
    </batch:step>
</batch:job>



An even worse pratice is using XML without a schema. But more about that in another post...

Keine Kommentare: