Changeset 1957


Ignore:
Timestamp:
05/22/12 21:23:29 (12 years ago)
Author:
oschonef
Message:
  • make numberOfRecords and maximumRecords a configuration option and expose values in explain
  • allow indenting of response
  • add extra request parameters for overriding maximum records and indenting (disabled by default)
  • remove getRawQuery() and getRawScanClause() from interface SRURequest
Location:
SRUServer/trunk/src/main/java/eu/clarin/sru/server
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequest.java

    r1881 r1957  
    101101
    102102    /**
    103      * Get the <em>query</em> parameter for the request in raw string format.
    104      * Only available for <em>searchRetrieve</em> requests.
    105      *
    106      * @return the raw query or <code>null</code> if not a
    107      *         <em>searchRetrieve</em> request
    108      */
    109     public String getRawQuery();
    110 
    111 
    112     /**
    113103     * Get the <em>startRecord</em> parameter of this request. Only available
    114104     * for <em>searchRetrieve</em> requests.
     
    123113     * Get the <em>maximumRecords</em> parameter of this request. Only available
    124114     * for <em>searchRetrieve</em> requests.
    125      *
    126      * @return the maximum number of records or <code>-1</code> if no value was
    127      *         supplied for this request
     115     * If no value was supplied with the request, the server will automatically
     116     * set a default value.
     117     *
     118     * @return the maximum number of records
    128119     */
    129120    public int getMaximumRecords();
     
    190181     */
    191182    public CQLNode getScanClause();
    192 
    193 
    194     /**
    195      * Get the <em>scanClause</em> parameter of this request in raw string
    196      * format. Only available for <em>scan</em> requests.
    197      *
    198      * @return the raw scan clause or <code>null</code> if not a <em>scan</em>
    199      *         request
    200      */
    201     public String getRawScanClause();
    202183
    203184
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java

    r1952 r1957  
    5353    private static final String RECORD_PACKING_STRING   = "string";
    5454    private static final String PARAM_EXTENSION_PREFIX  = "x-";
     55    private static final String X_UNLIMITED_RESULTSET   = "x-unlimited-resultset";
     56    private static final String X_INDENT_RESPONSE       = "x-indent-response";
     57    private final SRUServerConfig config;
    5558    private final HttpServletRequest request;
    5659    private List<SRUDiagnostic> diagnostics;
     
    186189
    187190
    188     SRURequestImpl(HttpServletRequest request, SRUVersion defaultVersion,
    189             SRURecordPacking defaultRecordPacking) {
     191    SRURequestImpl(SRUServerConfig config, HttpServletRequest request) {
     192        this.config        = config;
    190193        this.request       = request;
    191         this.version       = defaultVersion;
    192         this.recordPacking = defaultRecordPacking;
    193     }
    194 
    195 
    196     boolean checkParameters(SRUServerConfig config) {
     194    }
     195
     196
     197    boolean checkParameters() {
    197198        // parse mandatory operation parameter
    198199        final String op = getParameter(PARAM_OPERATION, false);
     
    386387
    387388
     389    SRUVersion getRawVersion() {
     390        return version;
     391    }
     392
     393
     394    SRURecordPacking getRawRecordPacking() {
     395        return recordPacking;
     396    }
     397
     398
     399    String getRawQuery() {
     400        return rawQuery;
     401    }
     402
     403
     404    int getRawMaximumRecords() {
     405        return maximumRecords;
     406    }
     407
     408
     409    String getRawScanClause() {
     410        return rawScanClause;
     411    }
     412
     413
     414    int getIndentResponse() {
     415        if (config.allowOverrideIndentResponse()) {
     416            String s = getExtraRequestData(X_INDENT_RESPONSE);
     417            if (s != null) {
     418                try {
     419                    int x = Integer.parseInt(s);
     420                    if ((x > -2) && (x < 9)) {
     421                        return x;
     422                    }
     423                } catch (NumberFormatException e) {
     424                    /* IGNORE */
     425                }
     426            }
     427        }
     428        return config.getIndentResponse();
     429    }
     430
     431
    388432    @Override
    389433    public SRUOperation getOperation() {
     
    394438    @Override
    395439    public SRUVersion getVersion() {
    396         return version;
     440        return (version != null) ? version : config.getDefaultVersion();
    397441    }
    398442
     
    403447            throw new NullPointerException("version == null");
    404448        }
    405         return this.version.equals(version);
     449        return getVersion().equals(version);
    406450    }
    407451
     
    418462            throw new IllegalArgumentException("min > max");
    419463        }
    420         return (min.getVersionNumber() >= version.getVersionNumber()) &&
    421                 (version.getVersionNumber() <= max.getVersionNumber());
     464        final SRUVersion v = getVersion();
     465        return (min.getVersionNumber() >= v.getVersionNumber()) &&
     466                (v.getVersionNumber() <= max.getVersionNumber());
    422467    }
    423468
     
    425470    @Override
    426471    public SRURecordPacking getRecordPacking() {
    427         return recordPacking;
     472        return (recordPacking != null)
     473                ? recordPacking
     474                : config.getDeaultRecordPacking();
    428475    }
    429476
     
    436483
    437484    @Override
    438     public String getRawQuery() {
    439         return rawQuery;
    440     }
    441 
    442 
    443     @Override
    444485    public int getStartRecord() {
    445486        return startRecord;
     
    449490    @Override
    450491    public int getMaximumRecords() {
    451         return maximumRecords;
     492        if (config.allowOverrideIndentResponse() &&
     493                (getExtraRequestData(X_UNLIMITED_RESULTSET) != null)) {
     494            return -1;
     495        }
     496        if (maximumRecords == -1) {
     497            return config.getNumberOfRecords();
     498        } else {
     499            if (maximumRecords > config.getMaximumRecords()) {
     500                return config.getMaximumRecords();
     501            } else {
     502                return maximumRecords;
     503            }
     504        }
    452505    }
    453506
     
    488541    }
    489542
    490 
    491     @Override
    492     public String getRawScanClause() {
    493         return rawScanClause;
    494     }
    495543
    496544    @Override
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java

    r1955 r1957  
    4848 * public class MySRUServlet extends HttpServlet {
    4949 *     private transient SRUServer sruServer;
    50  * 
    51  * 
     50 *
     51 *
    5252 *     public void init() throws ServletException {
    5353 *         final ServletContext ctx = getServletContext();
     
    5858 *                 throw new ServletException(&quot;not found, url == null&quot;);
    5959 *             }
    60  * 
     60 *
    6161 *             // get additional runtime configuration from Servlet context
    6262 *             HashMap&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
     
    6969 *                 }
    7070 *             }
    71  * 
     71 *
    7272 *             SRUServerConfig config = SRUServerConfig.parse(params,
    7373 *                     url.openStream());
     
    7878 *         }
    7979 *     }
    80  * 
    81  * 
     80 *
     81 *
    8282 *     protected void doGet(HttpServletRequest request,
    8383 *             HttpServletResponse response) throws ServletException, IOException {
    8484 *         sruServer.handleRequest(request, response);
    8585 *     }
    86  * 
    87  * 
     86 *
     87 *
    8888 *     protected void doPost(HttpServletRequest request,
    8989 *             HttpServletResponse response) throws ServletException, IOException {
     
    9292 * }
    9393 * </pre>
    94  * 
     94 *
    9595 * @see SRUServerConfig
    9696 * @see SRUSearchEngine
     
    123123    /**
    124124     * Constructor.
    125      * 
     125     *
    126126     * @param config
    127127     *            a SRUEndpointConfig object
     
    149149    /**
    150150     * Handle a SRL/CQL request.
    151      * 
     151     *
    152152     * @param request
    153153     *            a HttpServletRequest request
     
    157157    public void handleRequest(HttpServletRequest request,
    158158            HttpServletResponse response) {
    159         final SRURequestImpl req = new SRURequestImpl(request,
    160                 config.getDefaultVersion(), config.getDeaultRecordPacking());
     159        final SRURequestImpl req = new SRURequestImpl(config, request);
    161160        try {
    162161            // set response properties
     
    168167
    169168            try {
    170                 if (req.checkParameters(config)) {
     169                if (req.checkParameters()) {
    171170                    switch (req.getOperation()) {
    172171                    case EXPLAIN:
     
    229228        // commence explain ...
    230229        SRUExplainResult result = searchEngine.explain(config,
    231                 (SRURequest) request, (SRUDiagnosticList) request);
     230                request, request);
    232231
    233232        // send results
     
    272271        out.writeEndElement(); // "host" element
    273272        out.writeStartElement(SRU_EXPLAIN_NS, "port");
    274         out.writeCharacters(config.getPort());
     273        out.writeCharacters(Integer.toString(config.getPort()));
    275274        out.writeEndElement(); // "port" element
    276275        out.writeStartElement(SRU_EXPLAIN_NS, "database");
     
    372371
    373372        // explain/configInfo
     373        out.writeStartElement(SRU_EXPLAIN_NS, "configInfo");
     374        // numberOfRecords (default)
     375        out.writeStartElement(SRU_EXPLAIN_NS, "default");
     376        out.writeAttribute("type", "numberOfRecords");
     377        out.writeCharacters(Integer.toString(config.getNumberOfRecords()));
     378        out.writeEndElement(); // default" element
     379
     380        // maximumRecords (setting)
     381        out.writeStartElement(SRU_EXPLAIN_NS, "setting");
     382        out.writeAttribute("type", "maximumRecords");
     383        out.writeCharacters(Integer.toString(config.getMaximumRecords()));
     384        out.writeEndElement(); // "setting" element
     385
     386        out.writeEndElement(); // "configInfo" element
     387
    374388        out.writeEndElement(); // "explain" element
    375389
     
    406420        // commence scan
    407421        final SRUScanResultSet result = searchEngine.scan(config,
    408                 (SRURequest) request, (SRUDiagnosticList) request);
     422                request, request);
    409423        if (result == null) {
    410424            throw new SRUException(SRUConstants.SRU_UNSUPPORTED_OPERATION,
     
    508522        // commence search ...
    509523        final SRUSearchResultSet result = searchEngine.search(config,
    510                 (SRURequest) request, (SRUDiagnosticList) request);
     524                request, request);
    511525        if (result == null) {
    512526            throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR,
     
    777791
    778792    private void writeEchoedExplainRequest(SRUXMLStreamWriter out,
    779             SRURequest request) throws XMLStreamException,
     793            SRURequestImpl request) throws XMLStreamException,
    780794            SRUException {
    781795        // echoedSearchRetrieveRequest
     
    783797
    784798        // echoedExplainRequest/version
    785         writeVersion(out, request.getVersion());
     799        if (request.getRawVersion() != null) {
     800            writeVersion(out, request.getRawVersion());
     801        }
    786802
    787803        // echoedExplainRequest/recordPacking
    788         writeRecordPacking(out, request.getRecordPacking());
     804        if (request.getRawRecordPacking() != null) {
     805            writeRecordPacking(out, request.getRawRecordPacking());
     806        }
    789807
    790808        // echoedExplainRequest/stylesheet
     
    805823
    806824    private void writeEchoedScanRequest(SRUXMLStreamWriter out,
    807             SRURequest request, CQLNode cql) throws XMLStreamException,
     825            SRURequestImpl request, CQLNode cql) throws XMLStreamException,
    808826            SRUException {
    809827        // echoedScanRequest
     
    811829
    812830        // echoedScanRequest/version
    813         writeVersion(out, request.getVersion());
     831        if (request.getRawVersion() != null) {
     832            writeVersion(out, request.getRawVersion());
     833        }
    814834
    815835        // echoedScanRequest/scanClause
     
    857877
    858878    private void writeEchoedSearchRetrieveRequest(SRUXMLStreamWriter out,
    859             SRURequest request, CQLNode cql) throws XMLStreamException,
     879            SRURequestImpl request, CQLNode cql) throws XMLStreamException,
    860880            SRUException {
    861881        // echoedSearchRetrieveRequest
     
    863883
    864884        // echoedSearchRetrieveRequest/version
    865         writeVersion(out, request.getVersion());
     885        if (request.getRawVersion() != null) {
     886            writeVersion(out, request.getRawVersion());
     887        }
    866888
    867889        // echoedSearchRetrieveRequest/query
     
    885907
    886908        // echoedSearchRetrieveRequest/maximumRecords
    887         if (request.getMaximumRecords() > 0) {
     909        if (request.getRawMaximumRecords() > 0) {
    888910            out.writeStartElement(SRU_NS, "maximumRecords");
    889             out.writeCharacters(Integer.toString(request.getMaximumRecords()));
     911            out.writeCharacters(
     912                    Integer.toString(request.getRawMaximumRecords()));
    890913            out.writeEndElement(); // "startRecord" element
    891914        }
    892915
    893916        // echoedSearchRetrieveRequest/recordPacking
    894         writeRecordPacking(out, request.getRecordPacking());
     917        if (request.getRawRecordPacking() != null) {
     918            writeRecordPacking(out, request.getRawRecordPacking());
     919        }
    895920
    896921        // echoedSearchRetrieveRequest/recordSchema
     
    10111036    }
    10121037
    1013    
    1014     private static int getIndent(SRURequestImpl request) {
    1015         return -1;
     1038
     1039    private int getIndent(SRURequestImpl request) {
     1040        return request.getIndentResponse();
    10161041    }
    10171042
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServerConfig.java

    r1890 r1957  
    5555/**
    5656 * SRU server configuration.
    57  * 
     57 *
    5858 * <p>
    5959 * Example:
     
    6565 *     throw new ServletException(&quot;not found, url == null&quot;);
    6666 * }
    67  * 
     67 *
    6868 * // other runtime configuration, usually obtained from servlet context
    6969 * HashMap&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
     
    7575 * SRUServerConfig config = SRUServerConfig.parse(params, url);
    7676 * </pre>
    77  * 
     77 *
    7878 * <p>
    7979 * The XML configuration file must validate against the "sru-server-config.xsd"
     
    8383 */
    8484public final class SRUServerConfig {
    85     public static final String SRU_TRANSPORT     = "sru.transport";
    86     public static final String SRU_HOST          = "sru.host";
    87     public static final String SRU_PORT          = "sru.port";
    88     public static final String SRU_DATABASE      = "sru.database";
    89     public static final String SRU_ECHO_REQUESTS = "sru.echoRequests";
     85    public static final String SRU_TRANSPORT         = "sru.transport";
     86    public static final String SRU_HOST              = "sru.host";
     87    public static final String SRU_PORT              = "sru.port";
     88    public static final String SRU_DATABASE          = "sru.database";
     89    public static final String SRU_NUMBER_OF_RECORDS = "sru.numberOfRecords";
     90    public static final String SRU_MAXIMUM_RECORDS   = "sru.maximumRecords";
     91    public static final String SRU_ECHO_REQUESTS     = "sru.echoRequests";
     92    public static final String SRU_INDENT_RESPONSE   = "sru.indentResponse";
     93    public static final String SRU_ALLOW_OVERRIDE_MAXIMUM_RECORDS =
     94            "sru.allowOverrideMaximumRecords";
     95    public static final String SRU_ALLOW_OVERRIDE_INDENT_RESPONSE =
     96            "sru.allowOverrideIndentResponse";
     97    public static final int DEFAULT_NUMBER_OF_RECORDS = 100;
     98    public static final int DEFAULT_MAXIMUM_RECORDS = 250;
    9099    private static final String CONFIG_FILE_NAMESPACE_URI =
    91100            "http://www.clarin.eu/sru-server/1.0/";
     
    417426    private final String transport;
    418427    private final String host;
    419     private final String port;
     428    private final int port;
    420429    private final String database;
     430    private final int numberOfRecords;
     431    private final int maximumRecords;
    421432    private final boolean echoRequests;
     433    private final int indentResponse;
     434    private final boolean allowOverrideMaximumRecords;
     435    private final boolean allowOverrideIndentResponse;
    422436    private final String baseUrl;
    423437    private final DatabaseInfo databaseInfo;
     
    426440
    427441
    428     private SRUServerConfig(String transport, String host, String port,
    429             String database, boolean echoRequests, DatabaseInfo databaseinfo,
    430             IndexInfo indexInfo, List<SchemaInfo> schemaInfo) {
    431         this.transport    = transport;
    432         this.host         = host;
    433         this.port         = port;
    434         this.database     = database;
    435         this.databaseInfo = databaseinfo;
    436         this.indexInfo    = indexInfo;
     442    private SRUServerConfig(String transport, String host, int port,
     443            String database, int numberOfRecords, int maximumRecords,
     444            boolean echoRequests, int indentResponse,
     445            boolean allowOverrideMaximumRecords,
     446            boolean allowOverrideIndentResponse,
     447            DatabaseInfo databaseinfo, IndexInfo indexInfo,
     448            List<SchemaInfo> schemaInfo) {
     449        this.transport                   = transport;
     450        this.host                        = host;
     451        this.port                        = port;
     452        this.database                    = database;
     453        this.numberOfRecords             = numberOfRecords;
     454        this.maximumRecords              = maximumRecords;
     455        this.echoRequests                = echoRequests;
     456        this.indentResponse              = indentResponse;
     457        this.allowOverrideMaximumRecords = allowOverrideMaximumRecords;
     458        this.allowOverrideIndentResponse = allowOverrideIndentResponse;
     459        this.databaseInfo                = databaseinfo;
     460        this.indexInfo                   = indexInfo;
    437461        if ((schemaInfo != null) && !schemaInfo.isEmpty()) {
    438462            this.schemaInfo = Collections.unmodifiableList(schemaInfo);
     
    440464            this.schemaInfo = null;
    441465        }
    442         this.echoRequests = echoRequests;
    443466
    444467        // build baseUrl
    445468        StringBuilder sb = new StringBuilder();
    446469        sb.append(host);
    447         if (!"80".equals(port)) {
     470        if (port != 80) {
    448471            sb.append(":").append(port);
    449472        }
     
    478501
    479502
    480     public String getPort() {
     503    public int getPort() {
    481504        return port;
    482505    }
     
    490513    public String getBaseUrl() {
    491514        return baseUrl;
     515    }
     516
     517
     518    public int getNumberOfRecords() {
     519        return numberOfRecords;
     520    }
     521
     522
     523    public int getMaximumRecords() {
     524        return maximumRecords;
     525    }
     526
     527
     528    public int getIndentResponse() {
     529        return indentResponse;
     530    }
     531
     532
     533    public boolean allowOverrideMaximumRecords() {
     534        return allowOverrideMaximumRecords;
     535    }
     536
     537
     538    public boolean allowOverrideIndentResponse() {
     539        return allowOverrideIndentResponse;
    492540    }
    493541
     
    539587     * Parse a SRU server XML configuration file and create an configuration
    540588     * object from it.
    541      * 
     589     *
    542590     * @param params
    543591     *            additional settings
     
    663711            }
    664712
    665             String port = params.get(SRU_PORT);
    666             if ((port == null) || port.isEmpty()) {
    667                 throw new SRUConfigException("parameter \"" + SRU_PORT +
    668                         "\" is mandatory");
    669             }
    670             // sanity check
    671             try {
    672                 int num = Integer.parseInt(port);
    673                 if ((num < 1) && (num > 65535)) {
    674                     throw new SRUConfigException("parameter \"" + SRU_PORT +
    675                             "\" must be between 1 and 65535");
    676                 }
    677             } catch (NumberFormatException e) {
    678                 throw new SRUConfigException("parameter \"" + SRU_PORT +
    679                         "\" must be nummerical");
    680             }
     713            int port = parseNumber(params, SRU_PORT, true, -1, 1, 65535);
    681714
    682715            String database = params.get(SRU_DATABASE);
     
    686719            }
    687720
    688             // cleanup: remove leading slashed 
     721            // cleanup: remove leading slashed
    689722            while (database.startsWith("/")) {
    690723                database = database.substring(1);
    691724            }
    692725
    693             String s;
    694             boolean echoRequests = false;
    695             if ((s = params.get(SRU_ECHO_REQUESTS)) != null) {
    696                 echoRequests = Boolean.valueOf(s).booleanValue();
    697             }
     726
     727            int numberOfRecords = parseNumber(params, SRU_NUMBER_OF_RECORDS,
     728                    false, DEFAULT_NUMBER_OF_RECORDS, 1, -1);
     729
     730            int maximumRecords = parseNumber(params, SRU_MAXIMUM_RECORDS,
     731                    false, DEFAULT_MAXIMUM_RECORDS, numberOfRecords, -1);
     732
     733            boolean echoRequests = parseBoolean(params, SRU_ECHO_REQUESTS,
     734                    false, true);
     735
     736            int indentResponse = parseNumber(params, SRU_INDENT_RESPONSE,
     737                    false, -1, -1, 8);
     738
     739            boolean allowOverrideMaximumRecords = parseBoolean(params,
     740                    SRU_ALLOW_OVERRIDE_MAXIMUM_RECORDS, false, false);
     741
     742            boolean allowOverrideIndentResponse = parseBoolean(params,
     743                    SRU_ALLOW_OVERRIDE_INDENT_RESPONSE, false, false);
    698744
    699745            return new SRUServerConfig(transport, host, port, database,
    700                     echoRequests, databaseInfo, indexInfo,
     746                    numberOfRecords, maximumRecords, echoRequests,
     747                    indentResponse, allowOverrideMaximumRecords,
     748                    allowOverrideIndentResponse, databaseInfo, indexInfo,
    701749                    schemaInfo);
    702750        } catch (IOException e) {
     
    710758        } catch (SRUConfigException e) {
    711759            throw e;
     760        }
     761    }
     762
     763
     764    private static int parseNumber(Map<String, String> params, String name,
     765            boolean mandatory, int defaultValue, int minValue, int maxValue)
     766            throws SRUConfigException {
     767        String value = params.get(name);
     768        if ((value == null) || value.isEmpty()) {
     769            if (mandatory) {
     770                throw new SRUConfigException("parameter \"" + name +
     771                        "\" is mandatory");
     772            } else {
     773                return defaultValue;
     774            }
     775        } else {
     776            try {
     777                int num = Integer.parseInt(value);
     778
     779                // sanity checks
     780                if ((minValue != -1) && (maxValue != -1)) {
     781                    if ((num < minValue) || (num > maxValue)) {
     782                        throw new SRUConfigException("parameter \"" + name +
     783                                "\" must be between " + minValue + " and " +
     784                                maxValue + ": " + num);
     785                    }
     786                } else {
     787                    if ((minValue != -1) && (num < minValue)) {
     788                        throw new SRUConfigException("parameter \"" + name +
     789                                "\" must be larger than " + minValue + ": " +
     790                                num);
     791
     792                    }
     793                    if ((maxValue != -1) && (num > maxValue)) {
     794                        throw new SRUConfigException("parameter \"" + name +
     795                                "\" must be smaller than " + maxValue + ": " +
     796                                num);
     797                    }
     798                }
     799                return num;
     800            } catch (NumberFormatException e) {
     801                throw new SRUConfigException("parameter \"" + name +
     802                        "\" must be nummerical and less than " +
     803                        Integer.MAX_VALUE + ": " + value);
     804            }
     805        }
     806    }
     807
     808
     809    private static boolean parseBoolean(Map<String, String> params,
     810            String name, boolean mandatory, boolean defaultValue)
     811            throws SRUConfigException {
     812        String value = params.get(name);
     813        if ((value == null) || value.isEmpty()) {
     814            if (mandatory) {
     815                throw new SRUConfigException("parameter \"" + name +
     816                        "\" is mandatory");
     817            } else {
     818                return defaultValue;
     819            }
     820        } else {
     821            return Boolean.valueOf(value).booleanValue();
    712822        }
    713823    }
     
    804914                            if (set.isEmpty()) {
    805915                                throw new SRUConfigException("attribute 'set'" +
    806                                         " on element '/indexInfo/index/map/" + 
     916                                        " on element '/indexInfo/index/map/" +
    807917                                        "name' may not be empty");
    808918                            }
     
    819929                        can_sort, maps));
    820930            } // for
    821            
     931
    822932            // sanity check (/index/map/name/@set exists in any set/@name)
    823933            if (sets != null) {
     
    877987    }
    878988
    879    
     989
    880990    private static List<LocalizedString> buildList(XPath xpath, Document doc,
    881991            String expression) throws SRUConfigException,
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUXMLStreamWriter.java

    r1956 r1957  
    125125        this.xmlwriter = factory.createXMLStreamWriter(this.writer);
    126126
    127         if (indent > 1) {
     127        if (indent > 0) {
    128128            this.indent = indent;
    129129            this.state = IndentingState.SEEN_NOTHING;
Note: See TracChangeset for help on using the changeset viewer.