/** * Creates a new instance that wraps the given XML element. * * @param rootElement * xml content * @param systemId * the URL that is the source of the passed doc. If this URL is not available or unknown, the string * should contain the value of XMLFragment.DEFAULT_URL */ public XMLAdapter( OMElement rootElement, String systemId ) { setRootElement( rootElement ); setSystemId( systemId ); }
private AppSchema buildGMLSchema( String configURL, List<String> gmlSchemas ) throws FeatureStoreException { LOG.debug( "Building application schema from GML schema files." ); AppSchema appSchema = null; try { XMLAdapter resolver = new XMLAdapter(); resolver.setSystemId( configURL ); String[] schemaURLs = new String[gmlSchemas.size()]; int i = 0; for ( String gmlSchema : gmlSchemas ) { schemaURLs[i++] = resolver.resolve( gmlSchema.trim() ).toString(); } GMLAppSchemaReader decoder = null; if ( schemaURLs.length == 1 && schemaURLs[0].startsWith( "file:" ) ) { File file = new File( new URL( schemaURLs[0] ).toURI() ); decoder = new GMLAppSchemaReader( null, null, file ); } else { decoder = new GMLAppSchemaReader( null, null, schemaURLs ); } appSchema = decoder.extractAppSchema(); } catch ( Throwable t ) { t.printStackTrace(); String msg = "Error building GML application schema: " + t.getMessage(); throw new FeatureStoreException( msg ); } LOG.debug( "GML version: " + appSchema.getGMLSchema().getVersion() ); return appSchema; }
setSystemId( systemId );
workspace ); XMLAdapter adapter = new XMLAdapter(); adapter.setSystemId( configURL.toString() );
/** * Initializes this <code>XMLAdapter</code> with the content from the given <code>StringReader</code>. Sets the * SystemId, too. * * @param reader * source of the XML content * @param systemId * can not be null. This string should represent a URL that is related to the passed reader. If this URL * is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL * * @throws XMLProcessingException */ public void load( StringReader reader, String systemId ) throws XMLProcessingException { try { if ( systemId == null ) { throw new NullPointerException( "'systemId' must not be null!" ); } setSystemId( systemId ); XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader( reader ); StAXOMBuilder builder = new StAXOMBuilder( parser ); rootElement = builder.getDocumentElement(); } catch ( XMLStreamException e ) { throw new XMLProcessingException( e.getMessage(), e ); } catch ( OMException e ) { throw new XMLProcessingException( e.getMessage(), e ); } catch ( FactoryConfigurationError e ) { throw new XMLProcessingException( e.getMessage(), e ); } }
/** * Initializes this <code>XMLAdapter</code> with the content from the given <code>InputStream</code> and sets the * system id to the {@link #DEFAULT_URL} * * @param xmlStream * to load the xml from. * @throws XMLProcessingException */ public void load( XMLStreamReader xmlStream ) throws XMLProcessingException { if ( xmlStream.getEventType() != XMLStreamConstants.START_DOCUMENT ) { setRootElement( new StAXOMBuilder( new XMLStreamReaderDoc( xmlStream ) ).getDocumentElement() ); } else { setRootElement( new StAXOMBuilder( xmlStream ).getDocumentElement() ); } if ( xmlStream.getLocation() != null && xmlStream.getLocation().getSystemId() != null ) { setSystemId( xmlStream.getLocation().getSystemId() ); } }