3434import java .nio .ByteOrder ;
3535import java .util .HashMap ;
3636import java .util .Map ;
37+ import org .xml .sax .InputSource ;
3738
3839import static uk .co .real_logic .sbe .PrimitiveType .*;
3940import static uk .co .real_logic .sbe .xml .Presence .REQUIRED ;
@@ -94,16 +95,16 @@ public static void validate(final String xsdFilename, final InputStream in, fina
9495 }
9596
9697 /**
97- * Take an {@link InputStream } and parse it generating map of template ID to Message objects, types, and schema.
98+ * Take an {@link InputSource } and parse it generating map of template ID to Message objects, types, and schema.
9899 * <p>
99100 * Exceptions are passed back up for any problems.
100101 *
101- * @param in stream from which schema is read.
102+ * @param is inputSource from which schema is read. Ideally it will have the systemId property set to resolve relative references
102103 * @param options to be applied during parsing.
103104 * @return {@link MessageSchema} encoding for the schema.
104105 * @throws Exception on parsing error.
105106 */
106- public static MessageSchema parse (final InputStream in , final ParserOptions options ) throws Exception
107+ public static MessageSchema parse (final InputSource is , final ParserOptions options ) throws Exception
107108 {
108109 final DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
109110
@@ -114,7 +115,7 @@ public static MessageSchema parse(final InputStream in, final ParserOptions opti
114115 factory .setFeature ("http://apache.org/xml/features/xinclude/fixup-base-uris" , false );
115116 }
116117
117- final Document document = factory .newDocumentBuilder ().parse (in );
118+ final Document document = factory .newDocumentBuilder ().parse (is );
118119 final XPath xPath = XPathFactory .newInstance ().newXPath ();
119120
120121 final ErrorHandler errorHandler = new ErrorHandler (options );
@@ -133,6 +134,25 @@ public static MessageSchema parse(final InputStream in, final ParserOptions opti
133134 return messageSchema ;
134135 }
135136
137+ /**
138+ * Wraps an {@link InputStream} into an {@link InputSource} and delegates to
139+ * {@link #parse(org.xml.sax.InputSource, uk.co.real_logic.sbe.xml.ParserOptions) }.
140+ * <p>Note: this method does not the the {@link InputSource#setSystemId(java.lang.String) } property, however. It is recommended to use the
141+ * {@link #parse(org.xml.sax.InputSource, uk.co.real_logic.sbe.xml.ParserOptions) } method directly.</p>
142+ *
143+ * <p>
144+ * Exceptions are passed back up for any problems.
145+ *
146+ * @param in stream from which schema is read.
147+ * @param options to be applied during parsing.
148+ * @return {@link MessageSchema} encoding for the schema.
149+ * @throws Exception on parsing error.
150+ */
151+ public static MessageSchema parse (final InputStream in , final ParserOptions options ) throws Exception
152+ {
153+ return parse (new InputSource (in ), options );
154+ }
155+
136156 /**
137157 * Scan XML for all types (encodedDataType, compositeType, enumType, and setType) and save in map
138158 *
0 commit comments