org.apache.xmlbeans.XmlOptions Java Examples
The following examples show how to use
org.apache.xmlbeans.XmlOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateSensorResponseEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { EncoderRepository encoderRepository = new EncoderRepository(); SchemaRepository schemaRepository = new SchemaRepository(); schemaRepository.setEncoderRepository(encoderRepository); encoder = new UpdateSensorResponseEncoder(); encoder.setEncoderRepository(encoderRepository); encoder.setXmlOptions(XmlOptions::new); encoder.setSchemaRepository(schemaRepository); encoderRepository.setEncoders(Arrays.asList(encoder)); encoderRepository.init(); schemaRepository.init(); }
Example #2
Source File: GetDataAvailabilityXmlEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void init() { encoder = new GetDataAvailabilityXmlEncoder(); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders(Arrays.asList(encoder)); encoderRepository.init(); SchemaRepository schemaRepository = new SchemaRepository(); schemaRepository.setEncoderRepository(encoderRepository); schemaRepository.init(); encoder.setEncoderRepository(encoderRepository); encoder.setXmlOptions(XmlOptions::new); encoder.setSchemaRepository(schemaRepository); encoder.setValidate(true); }
Example #3
Source File: GetFeatureOfInterestResponseDecoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { decoderRepository = new DecoderRepository(); Producer<XmlOptions> xmlOptions = XmlOptions::new; List<Decoder<?, ?>> decoders = Stream.of(new GetFeatureOfInterestResponseDocumentDecoder(), new GmlDecoderv321(), new OmDecoderv20(), new SweCommonDecoderV20(), new SamplingDecoderv20(), new WmlMonitoringPointDecoderv20()) .map(decoder -> { decoder.setDecoderRepository(decoderRepository); decoder.setXmlOptions(xmlOptions); return decoder; }).collect(toList()); decoderRepository.setDecoders(decoders); decoderRepository.init(); }
Example #4
Source File: FesEncoderv20Test.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void initInstance() { instance = new FesEncoderv20(); Producer<XmlOptions> options = () -> new XmlOptions(); instance.setXmlOptions(options); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders(Arrays.asList(instance)); encoderRepository.init(); SchemaRepository schemaRepository = new SchemaRepository(); schemaRepository.setEncoderRepository(encoderRepository); schemaRepository.init(); instance.setEncoderRepository(encoderRepository); instance.setXmlOptions(options); }
Example #5
Source File: DeleteSensorResponseEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void setup() { instance = new DeleteSensorResponseEncoder(); Producer<XmlOptions> options = () -> new XmlOptions(); instance.setXmlOptions(options); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders(Arrays.asList(instance)); encoderRepository.init(); SchemaRepository schemaRepository = new SchemaRepository(); schemaRepository.setEncoderRepository(encoderRepository); schemaRepository.init(); instance.setSchemaRepository(schemaRepository); instance.setEncoderRepository(encoderRepository); instance.setXmlOptions(options); schemaRepository.init(); }
Example #6
Source File: Soap12Encoder.java From arctic-sea with Apache License 2.0 | 6 votes |
@Override public void encode(Object element, OutputStream outputStream, EncodingContext ctx) throws EncodingException { if (element instanceof SoapResponse) { try { EncodingContext context = ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()) .with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions); new Soap12XmlStreamWriter(context, outputStream, (SoapResponse) element).write(); } catch (XMLStreamException ex) { throw new EncodingException(ex); } } else { try { encode(element, ctx).save(outputStream, getXmlOptions()); } catch (IOException ioe) { throw new EncodingException("Error while writing element to stream!", ioe); } } }
Example #7
Source File: InspireOmObservationEncoder.java From arctic-sea with Apache License 2.0 | 6 votes |
@Override public void encode(Object element, OutputStream outputStream, EncodingContext ctx) throws EncodingException { try { if (element instanceof OmObservation && InspireOMSOConstants.OBS_TYPE_POINT_TIME_SERIES_OBSERVATION .equals(((OmObservation) element).getObservationConstellation().getObservationType())) { new PointTimeSeriesObservationXmlStreamWriter( ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()) .with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions), outputStream, (OmObservation) element).write(); } else { // writeIndent(encodingValues.getIndent(), outputStream); encode(element, ctx).save(outputStream, getXmlOptions()); } } catch (IOException | XMLStreamException e) { throw new EncodingException("Error while writing element to stream!", e); } }
Example #8
Source File: XmlStreamWriter.java From arctic-sea with Apache License 2.0 | 6 votes |
public XmlStreamWriter(EncodingContext context, OutputStream outputStream, S element) throws XMLStreamException { this.context = Objects.requireNonNull(context); this.outputStream = Objects.requireNonNull(outputStream); this.element = element; this.encoderRepository = context.require(EncoderFlags.ENCODER_REPOSITORY); this.xmlOptions = context.get(XmlEncoderFlags.XML_OPTIONS, XmlOptions::new); this.xmlVersion = context.get(XmlEncoderFlags.XML_VERSION, "1.0"); this.xmlEncoding = context.get(EncoderFlags.ENCODING, StandardCharsets.UTF_8.name()); this.embedded = context.getBoolean(StreamingEncoderFlags.EMBEDDED); if (context.has(XmlStreamEncoderFlags.XML_WRITER)) { this.writer = context.require(XmlStreamEncoderFlags.XML_WRITER); this.close = false; } else { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); if (outputFactory.isPropertySupported(OUTPUT_PROPERTY_ESCAPE_CHARACTERS)) { outputFactory.setProperty(OUTPUT_PROPERTY_ESCAPE_CHARACTERS, false); } this.writer = new IndentingXMLStreamWriter(outputFactory .createXMLStreamWriter(this.outputStream, this.xmlEncoding), INDENTATION); this.context = this.context.with(XmlStreamEncoderFlags.XML_WRITER, this.writer); this.close = true; } }
Example #9
Source File: DhlXTeeServiceImpl.java From j-road with Apache License 2.0 | 6 votes |
/** * Writes the document into given stream. Removes namespace usage from SignedDoc element (Digidoc container) Amphora test * environment is not capable of receiving such xml */ private void writeXmlObject(XmlObject xmlObject, OutputStream outputStream) { XmlOptions options = new XmlOptions(); options.setCharacterEncoding(DVK_MESSAGE_CHARSET); { // fix DigiDoc client bug (also present with PostiPoiss doc-management-system) // they don't accept that SignedDoc have nameSpace alias set options.setSavePrettyPrint(); HashMap<String, String> suggestedPrefixes = new HashMap<String, String>(2); suggestedPrefixes.put("http://www.sk.ee/DigiDoc/v1.3.0#", ""); // suggestedPrefixes.put("http://www.sk.ee/DigiDoc/v1.4.0#", ""); options.setSaveSuggestedPrefixes(suggestedPrefixes); } try { xmlObject.save(outputStream, options); writeXmlObjectToSentDocumentsFolder(xmlObject, options); } catch (IOException e) { log.error("Writing document failed", e); throw new java.lang.RuntimeException(e); } }
Example #10
Source File: ProcessDocumentEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void initDecoder() { super.initDecoder(); EncoderRepository encoderRepository = new EncoderRepository(); Producer<XmlOptions> options = () -> new XmlOptions(); docEncoder = new ProcessDocumentEncoder(); docEncoder.setEncoderRepository(encoderRepository); docEncoder.setXmlOptions(options); typeEncoder = new ProcessTypeEncoder(); typeEncoder.setEncoderRepository(encoderRepository); typeEncoder.setXmlOptions(options); encoderRepository.setEncoders(Arrays.asList(docEncoder, typeEncoder)); encoderRepository.init(); }
Example #11
Source File: DhlXTeeServiceImpl.java From j-road with Apache License 2.0 | 6 votes |
private byte[] createMarkDocumentsReceivedV2AttachmentBody(Collection<TagasisideType> receivedDocsInfos) { TagasisideArrayType receivedDocs = TagasisideArrayType.Factory.newInstance(); receivedDocs.setItemArray(receivedDocsInfos.toArray(new TagasisideType[receivedDocsInfos.size()])); if (log.isTraceEnabled()) { log.trace("created markDocumentsReceivedV2 attachmentBody: " + receivedDocs); } XmlOptions options = new XmlOptions(); options.setCharacterEncoding(DVK_MESSAGE_CHARSET); { // When marking documents received, with version 2 // they don't accept that item children, such as dhl_id and fault have nameSpace prefixes set HashMap<String, String> suggestedPrefixes = new HashMap<String, String>(2); suggestedPrefixes.put("http://www.riik.ee/schemas/dhl", ""); options.setSaveSuggestedPrefixes(suggestedPrefixes); options.setSaveNoXmlDecl(); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { receivedDocs.save(bos, options); String s = new String(bos.toByteArray(), DVK_MESSAGE_CHARSET); return gzipAndEncodeString(s); } catch (IOException e) { throw new RuntimeException("Failed to create markDocumentsReceivedV2 request attachmentBody", e); } }
Example #12
Source File: DefaultEbicsRootElement.java From axelor-open-suite with GNU Affero General Public License v3.0 | 6 votes |
@Override public void validate() throws AxelorException { ArrayList<XmlError> validationMessages; boolean isValid; validationMessages = new ArrayList<XmlError>(); isValid = document.validate(new XmlOptions().setErrorListener(validationMessages)); if (!isValid) { String message; Iterator<XmlError> iter; iter = validationMessages.iterator(); message = ""; while (iter.hasNext()) { if (!message.equals("")) { message += ";"; } message += iter.next().getMessage(); } throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, message); } }
Example #13
Source File: EnvironmentalMonitoringFacilityTypeEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void initInstance() { instance = new EnvironmentalMonitoringFaciltityTypeEncoder(); Producer<XmlOptions> options = () -> new XmlOptions(); instance.setXmlOptions(options); InspireXmlEncoder inspireXmlEncoder = new InspireXmlEncoder(); IdentifierPropertyTypeEncoder identifierPropertyTypeEncoder = new IdentifierPropertyTypeEncoder(); GmlEncoderv321 gmlEncoderv321 = new GmlEncoderv321(); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders( Arrays.asList(instance, inspireXmlEncoder, identifierPropertyTypeEncoder, gmlEncoderv321)); encoderRepository.init(); instance.setEncoderRepository(encoderRepository); instance.setXmlOptions(options); inspireXmlEncoder.setEncoderRepository(encoderRepository); inspireXmlEncoder.setXmlOptions(options); identifierPropertyTypeEncoder.setEncoderRepository(encoderRepository); identifierPropertyTypeEncoder.setXmlOptions(options); gmlEncoderv321.setEncoderRepository(encoderRepository); gmlEncoderv321.setXmlOptions(options); }
Example #14
Source File: OmEncoderv20.java From arctic-sea with Apache License 2.0 | 6 votes |
@Override public void encode(Object objectToEncode, OutputStream outputStream, EncodingContext ctx) throws EncodingException { if (objectToEncode instanceof OmObservation) { try { new OmV20XmlStreamWriter( ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()) .with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions), outputStream, (OmObservation) objectToEncode).write(); } catch (XMLStreamException xmlse) { throw new EncodingException("Error while writing element to stream!", xmlse); } } else { super.encode(objectToEncode, ctx); } }
Example #15
Source File: TypeGen.java From j-road with Apache License 2.0 | 6 votes |
/** * Generates the XMLBeans source files. * * @param outputdir * @param basepackage * @throws XmlException * @throws URISyntaxException */ private static void generateSource(String outputdir, String xsbdir, String basepackage) throws XmlException, URISyntaxException { XmlObject[] schemasarr = new XmlObject[schemas.size()]; schemas.toArray(schemasarr); XmlOptions options = new XmlOptions(); options.setCompileDownloadUrls(); options.setGenerateJavaVersion("1.5"); options.setSchemaCodePrinter(new XteeSchemaCodePrinter(options)); XmlBeans.compileXmlBeans(null, null, schemasarr, new BasepackageBinder(basepackage), null, new SimpleFiler(outputdir, xsbdir), options); }
Example #16
Source File: DeleteObservationDecoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { DecoderRepository decoderRepository = new DecoderRepository(); decoder = new DeleteObservationDecoder(); decoder.setDecoderRepository(decoderRepository); decoder.setXmlOptions(XmlOptions::new); // GmlDecoderv321 gmlDecoderv321 = new GmlDecoderv321(); // gmlDecoderv321.setXmlOptions(XmlOptions::new); // gmlDecoderv321.setDecoderRepository(decoderRepository); // // SweCommonDecoderV20 sweCommonDecoderV20 = new SweCommonDecoderV20(); // sweCommonDecoderV20.setXmlOptions(XmlOptions::new); // sweCommonDecoderV20.setDecoderRepository(decoderRepository); decoderRepository.setDecoders(Arrays.asList(decoder)); decoderRepository.init(); correctXmlObject = DeleteObservationDocument.Factory.newInstance(); correctXmlObject.addNewDeleteObservation().setObservation(observationId); }
Example #17
Source File: SensorMLDecoderV20Test.java From arctic-sea with Apache License 2.0 | 6 votes |
private static SensorMLDecoderV20 getDecoder() { DecoderRepository decoderRepository = new DecoderRepository(); SensorMLDecoderV20 sensorMLDecoderV20 = new SensorMLDecoderV20(); sensorMLDecoderV20.setDecoderRepository(decoderRepository); sensorMLDecoderV20.setXmlOptions(XmlOptions::new); SweCommonDecoderV20 sweCommonDecoderV20 = new SweCommonDecoderV20(); sweCommonDecoderV20.setDecoderRepository(decoderRepository); sweCommonDecoderV20.setXmlOptions(XmlOptions::new); decoderRepository.setDecoders(Arrays.asList(sensorMLDecoderV20, sweCommonDecoderV20)); decoderRepository.init(); return sensorMLDecoderV20; }
Example #18
Source File: EnvironmentalMonitoringFacilityDocumentEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void initInstance() { instance = new EnvironmentalMonitoringFaciltityDocumentEncoder(); Producer<XmlOptions> options = () -> new XmlOptions(); instance.setXmlOptions(options); InspireXmlEncoder inspireXmlEncoder = new InspireXmlEncoder(); IdentifierPropertyTypeEncoder identifierPropertyTypeEncoder = new IdentifierPropertyTypeEncoder(); GmlEncoderv321 gmlEncoderv321 = new GmlEncoderv321(); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders( Arrays.asList(instance, inspireXmlEncoder, identifierPropertyTypeEncoder, gmlEncoderv321)); encoderRepository.init(); instance.setEncoderRepository(encoderRepository); instance.setXmlOptions(options); inspireXmlEncoder.setEncoderRepository(encoderRepository); inspireXmlEncoder.setXmlOptions(options); identifierPropertyTypeEncoder.setEncoderRepository(encoderRepository); identifierPropertyTypeEncoder.setXmlOptions(options); gmlEncoderv321.setEncoderRepository(encoderRepository); gmlEncoderv321.setXmlOptions(options); }
Example #19
Source File: AqdGetObservationResponseEncoder.java From arctic-sea with Apache License 2.0 | 6 votes |
@Override protected void create(GetObservationResponse response, OutputStream outputStream, EncodingContext ctx) throws EncodingException { FeatureCollection featureCollection = createFeatureCollection(response); EReportingHeader eReportingHeader; TimePeriod timePeriod; try { eReportingHeader = getEReportingHeader(getReportObligationType(response)); featureCollection.addMember(eReportingHeader); timePeriod = addToFeatureCollectionAndGetTimePeriod(featureCollection, response, eReportingHeader); } catch (OwsExceptionReport ex) { throw new EncodingException(ex); } if (!timePeriod.isEmpty()) { eReportingHeader.setReportingPeriod(Referenceable.of((Time) timePeriod)); } try { EncodingContext context = ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()) .with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions) .with(XmlEncoderFlags.ENCODE_NAMESPACE, OmConstants.NS_OM_2) .with(XmlBeansEncodingFlags.DOCUMENT); new AqdGetObservationResponseXmlStreamWriter(context, outputStream, featureCollection).write(); } catch (XMLStreamException xmlse) { throw new EncodingException("Error while writing element to stream!", xmlse); } }
Example #20
Source File: ConfigurationHelper.java From mdw with Apache License 2.0 | 6 votes |
public static boolean applyConfigChange(String fileName, String contents, boolean react) throws Exception { if (APPLICATION_CACHE.equals(fileName)) { ApplicationCacheDocument.Factory.parse(contents, new XmlOptions()); } String filepath = System.getProperty("mdw.config.location") + "/" + fileName; try (FileWriter wr = new FileWriter(new File(filepath))) { wr.write(contents); wr.flush(); } if (!react) return true; else return reactToConfigChange(fileName); }
Example #21
Source File: TypeGen.java From j-road with Apache License 2.0 | 6 votes |
/** * Return the schemas contained in the given wsdl:types node. * * @param typesNode * @param additionalNs * @return A collection of schemas found under the Node * @throws Exception */ private static Collection<XmlObject> getSchemas(Node typesNode, Map<String, String> additionalNs, String schemaPath) throws Exception { List<XmlObject> schemas = new ArrayList<XmlObject>(); NodeList schemaNodes = typesNode.getChildNodes(); XmlOptions options = new XmlOptions(); options.setLoadAdditionalNamespaces(additionalNs); for (int i = 0; i < schemaNodes.getLength(); i++) { Node schemaNode = schemaNodes.item(i); if (SCHEMA_NS.equals(schemaNode.getNamespaceURI()) && "schema".equals(schemaNode.getLocalName())) { XmlObject schema = XmlObject.Factory.parse(schemaNode, options); schema.documentProperties().setSourceName("file://" + schemaPath.replace(File.separator, "/") + "/"); schemas.add(schema); } else if (schemaNode.getNodeType() != Node.TEXT_NODE && schemaNode.getNodeType() != Node.COMMENT_NODE) { // TODO: Add xs:import support outside schemas. throw new IllegalStateException("Encountered unsupported element in WSDL types definition: ({" + schemaNode.getNamespaceURI() + "}" + schemaNode.getLocalName() + ")!"); } } return schemas; }
Example #22
Source File: DeleteResultTemplateDecoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { DecoderRepository decoderRepository = new DecoderRepository(); decoder = new DeleteResultTemplateDecoder(); decoder.setDecoderRepository(decoderRepository); decoder.setXmlOptions(XmlOptions::new); decoderRepository.setDecoders(Arrays.asList(decoder)); decoderRepository.init(); encodedRequest = DeleteResultTemplateDocument.Factory.newInstance(); drtt = encodedRequest.addNewDeleteResultTemplate(); drtt.setService("test-service"); drtt.setVersion("test-version"); }
Example #23
Source File: DefaultEbicsRootElement.java From ebics-java-client with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void validate() throws EbicsException { ArrayList<XmlError> validationMessages; boolean isValid; validationMessages = new ArrayList<XmlError>(); isValid = document.validate(new XmlOptions().setErrorListener(validationMessages)); if (!isValid) { String message; Iterator<XmlError> iter; iter = validationMessages.iterator(); message = ""; while (iter.hasNext()) { if (!message.equals("")) { message += ";"; } message += iter.next().getMessage(); } throw new EbicsException(message); } }
Example #24
Source File: MailMerge.java From poi-mail-merge with BSD 2-Clause "Simplified" License | 6 votes |
private static void appendBody(CTBody src, String append, boolean first) throws XmlException { XmlOptions optionsOuter = new XmlOptions(); optionsOuter.setSaveOuter(); String srcString = src.xmlText(); String prefix = srcString.substring(0,srcString.indexOf(">")+1); final String mainPart; // exclude template itself in first appending if(first) { mainPart = ""; } else { mainPart = srcString.substring(srcString.indexOf(">")+1,srcString.lastIndexOf("<")); } String suffix = srcString.substring( srcString.lastIndexOf("<") ); String addPart = append.substring(append.indexOf(">") + 1, append.lastIndexOf("<")); CTBody makeBody = CTBody.Factory.parse(prefix+mainPart+addPart+suffix); src.set(makeBody); }
Example #25
Source File: FesDecoderV20Test.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { decoderRepository = new DecoderRepository(); Producer<XmlOptions> xmlOptions = XmlOptions::new; List<Decoder<?, ?>> decoders = Stream.of(new GetFeatureOfInterestResponseDocumentDecoder(), new GmlDecoderv321(), new OmDecoderv20(), new SweCommonDecoderV20(), new SamplingDecoderv20(), new WmlMonitoringPointDecoderv20(), decoder) .map(decoder -> { decoder.setDecoderRepository(decoderRepository); decoder.setXmlOptions(xmlOptions); return decoder; }).collect(toList()); decoderRepository.setDecoders(decoders); decoderRepository.init(); }
Example #26
Source File: DeleteObservationEncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void initInstance() { instance = new DeleteObservationEncoder(); Producer<XmlOptions> options = () -> new XmlOptions(); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders(Arrays.asList(instance)); encoderRepository.init(); SchemaRepository schemaRepository = new SchemaRepository(); schemaRepository.setEncoderRepository(encoderRepository); schemaRepository.init(); instance.setSchemaRepository(schemaRepository); instance.setEncoderRepository(encoderRepository); instance.setXmlOptions(options); correctCoreResponse = new DeleteObservationResponse(DeleteObservationConstants.NS_SOSDO_1_0); correctCoreResponse.setObservationId(observationId); correctCoreResponse.setService(SosConstants.SOS); correctCoreResponse.setVersion(Sos2Constants.SERVICEVERSION); }
Example #27
Source File: OmDecoderV20Test.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { DecoderRepository decoderRepository = new DecoderRepository(); omDecoderv20 = new OmDecoderv20(); omDecoderv20.setDecoderRepository(decoderRepository); omDecoderv20.setXmlOptions(XmlOptions::new); GmlDecoderv321 gmlDecoderv321 = new GmlDecoderv321(); gmlDecoderv321.setXmlOptions(XmlOptions::new); gmlDecoderv321.setDecoderRepository(decoderRepository); SweCommonDecoderV20 sweCommonDecoderV20 = new SweCommonDecoderV20(); sweCommonDecoderV20.setXmlOptions(XmlOptions::new); sweCommonDecoderV20.setDecoderRepository(decoderRepository); decoderRepository.setDecoders(Arrays.asList(omDecoderv20, sweCommonDecoderV20, gmlDecoderv321)); decoderRepository.init(); }
Example #28
Source File: GetDataAvailabilityRequestDecoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeEach public void init() { this.decoderRepository = new DecoderRepository(); GetDataAvailabilityXmlDecoder decoder1 = new GetDataAvailabilityXmlDecoder(); decoder1.setXmlOptions(XmlOptions::new); decoder1.setDecoderRepository(this.decoderRepository); GetDataAvailabilityV20XmlDecoder decoder2 = new GetDataAvailabilityV20XmlDecoder(); decoder2.setDecoderRepository(this.decoderRepository); decoder2.setXmlOptions(XmlOptions::new); this.decoderRepository.setDecoders(Arrays.asList(decoder1, decoder2)); this.decoderRepository.init(); }
Example #29
Source File: DeleteObservationV20EncoderTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void initInstance() { instance = new DeleteObservationV20Encoder(); Producer<XmlOptions> options = () -> new XmlOptions(); instance.setXmlOptions(options); EncoderRepository encoderRepository = new EncoderRepository(); encoderRepository.setEncoders(Arrays.asList(instance)); encoderRepository.init(); SchemaRepository schemaRepository = new SchemaRepository(); schemaRepository.setEncoderRepository(encoderRepository); schemaRepository.init(); instance.setSchemaRepository(schemaRepository); instance.setEncoderRepository(encoderRepository); instance.setXmlOptions(options); correctCoreResponse = new DeleteObservationResponse(DeleteObservationConstants.NS_SOSDO_2_0); correctCoreResponse.setObservationId(observationId); correctCoreResponse.setService(Sos2Constants.SOS); correctCoreResponse.setVersion(Sos2Constants.SERVICEVERSION); }
Example #30
Source File: XmlDVReportService.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
public String generateSchema(File modelSchema,String fileName) throws XmlException, IOException{ if(fileName.endsWith((XmlDataValidationConstants.XML_LITERAL))){ SchemaGenerator schemaGenerator = new SchemaGenerator(); SchemaDocument schemaDocument; schemaDocument = schemaGenerator.generateSchema(modelSchema); StringWriter writer = new StringWriter(); schemaDocument.save(writer, new XmlOptions().setSavePrettyPrint()); String schema = writer.toString(); writer.close(); return schema; }else if(fileName.endsWith(XmlDataValidationConstants.XSD_LITERAL)){ StringBuffer buf = new StringBuffer(); BufferedReader in = new BufferedReader(new FileReader(modelSchema)); try { String line = null; while ((line = in.readLine()) != null) { buf.append(line); } } finally { in.close(); } return buf.toString(); }else{ LOGGER.error("Please provide a definition to validate"); return ""; } }