View Javadoc
1   /**
2    * Copyright (C) 2014-2018 Philip Helger (www.helger.com)
3    * philip[at]helger[dot]com
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    *         http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package com.helger.schematron.svrl;
18  
19  import javax.annotation.Nonnull;
20  import javax.annotation.Nullable;
21  import javax.annotation.concurrent.Immutable;
22  
23  import org.oclc.purl.dsdl.svrl.SchematronOutputType;
24  import org.w3c.dom.Document;
25  
26  import com.helger.commons.annotation.DevelopersNote;
27  import com.helger.commons.annotation.PresentForCodeCoverage;
28  
29  /**
30   * This is the XML writer for Schematron SVRL documents. It reads
31   * {@link SchematronOutputType} elements and converts them to W3C nodes. The
32   * writing itself is done with JAXB.
33   *
34   * @author Philip Helger
35   */
36  @Immutable
37  @Deprecated
38  @DevelopersNote ("Use SVRLMarshaller direct - much more flexibility")
39  public final class SVRLWriter
40  {
41    @PresentForCodeCoverage
42    private static final SVRLWriter.html#SVRLWriter">SVRLWriter s_aInstance = new SVRLWriter ();
43  
44    private SVRLWriter ()
45    {}
46  
47    /**
48     * Convert the passed schematron output element into an W3C Document node.
49     *
50     * @param aSchematronOutput
51     *        The schematron output to be converted. May not be <code>null</code>.
52     * @return <code>null</code> if conversion failed.
53     */
54    @Nullable
55    public static Document createXML (@Nonnull final SchematronOutputType aSchematronOutput)
56    {
57      return new SVRLMarshaller ().getAsDocument (aSchematronOutput);
58    }
59  
60    /**
61     * Utility method to directly convert the passed SVRL domain object to an XML
62     * string.
63     *
64     * @param aSchematronOutput
65     *        The SVRL domain object to be converted. May not be null.
66     * @return <code>null</code> if the passed domain object could not be
67     *         converted because of validation errors.
68     */
69    @Nullable
70    public static String createXMLString (@Nonnull final SchematronOutputType aSchematronOutput)
71    {
72      return new SVRLMarshaller ().getAsString (aSchematronOutput);
73    }
74  }