本文整理了Java中org.apache.sis.xml.XML.marshal()
方法的一些代码示例,展示了XML.marshal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XML.marshal()
方法的具体详情如下:
包路径:org.apache.sis.xml.XML
类名称:XML
方法名:marshal
[英]Marshal the given object into a string.
[中]将给定对象封送为字符串。
代码示例来源:origin: apache/sis
final String xml = XML.marshal(data);
代码示例来源:origin: apache/sis
final DefaultMetadata data = new DefaultMetadata();
data.setIdentificationInfo(singleton(identification));
final String xml = XML.marshal(data);
代码示例来源:origin: apache/sis
/**
* Tests (un)marshalling of an operation method.
*
* @throws JAXBException if an error occurred during marshalling or unmarshalling.
*/
@Test
public void testOperationMethod() throws JAXBException {
final String xml = XML.marshal(createMercatorMethod());
assertXmlEquals("<gml:OperationMethod xmlns:gml=\"" + Namespaces.GML + "\">\n" +
" <gml:name>Mercator (1SP)</gml:name>\n" +
" <gml:formula>See EPSG guide.</gml:formula>\n" +
" <gml:sourceDimensions>2</gml:sourceDimensions>\n" +
" <gml:targetDimensions>2</gml:targetDimensions>\n" +
" <gml:parameter>\n" +
" <gml:OperationParameter gml:id=\"epsg-parameter-8801\">\n" +
" <gml:identifier codeSpace=\"IOGP\">urn:ogc:def:parameter:EPSG::8801</gml:identifier>\n" +
" <gml:name codeSpace=\"EPSG\">Latitude of natural origin</gml:name>\n" +
" </gml:OperationParameter>\n" +
" </gml:parameter>\n" +
" <gml:parameter>\n" +
" <gml:OperationParameter gml:id=\"epsg-parameter-8802\">\n" +
" <gml:identifier codeSpace=\"IOGP\">urn:ogc:def:parameter:EPSG::8802</gml:identifier>\n" +
" <gml:name codeSpace=\"EPSG\">Longitude of natural origin</gml:name>\n" +
" </gml:OperationParameter>\n" +
" </gml:parameter>\n" +
"</gml:OperationMethod>", xml, "xmlns:*");
final OperationMethod method = (OperationMethod) XML.unmarshal(xml);
verifyMethod(method);
Validators.validate(method);
}
代码示例来源:origin: apache/sis
final String actual = XML.marshal(citation);
assertXmlEquals(REFERENCED_XML, actual, "xmlns:*");
assertEquals(citation, XML.unmarshal(actual));
代码示例来源:origin: apache/sis
final String actual = XML.marshal(citation);
assertXmlEquals(IDENTIFIED_XML, actual, "xmlns:*");
assertEquals(citation, XML.unmarshal(actual));
代码示例来源:origin: apache/sis
/**
* Tests (un)marshalling of a parameter descriptor.
*
* @throws JAXBException if an error occurred during marshalling or unmarshalling.
*/
@Test
public void testDescriptor() throws JAXBException {
final DefaultParameterDescriptor<Double> descriptor = new DefaultParameterDescriptor<>(
Collections.singletonMap(DefaultParameterDescriptor.NAME_KEY, "A descriptor"),
0, 1, Double.class, null, null, null);
final String xml = XML.marshal(descriptor);
assertXmlEquals(
"<gml:OperationParameter xmlns:gml=\"" + Namespaces.GML + "\">\n"
+ " <gml:name>A descriptor</gml:name>\n"
+ " <gml:minimumOccurs>0</gml:minimumOccurs>\n"
+ "</gml:OperationParameter>", xml, "xmlns:*");
final DefaultParameterDescriptor<?> r = (DefaultParameterDescriptor<?>) XML.unmarshal(xml);
assertEquals("name", "A descriptor", r.getName().getCode());
assertEquals("minimumOccurs", 0, r.getMinimumOccurs());
assertEquals("maximumOccurs", 1, r.getMaximumOccurs());
/*
* A DefaultParameterDescriptor with null 'valueClass' is illegal, but there is no way we can guess
* this information if the <gml:OperationParameter> element was not a child of <gml:ParameterValue>.
* The current implementation leaves 'valueClass' to null despite being illegal. This behavior may
* change in any future Apache SIS version.
*/
assertNull("valueDomain", r.getValueDomain());
assertNull("valueClass", r.getValueClass()); // May change in any future SIS release.
}
代码示例来源:origin: apache/sis
final String actual = XML.marshal(citation);
assertXmlEquals(IDENTIFIED_XML, actual, "xmlns:*");
assertEquals(citation, XML.unmarshal(actual));
代码示例来源:origin: apache/sis
throws JAXBException
final String xml = XML.marshal(parameter);
assertXmlEquals(expected, xml, "xmlns:*");
final DefaultParameterValue<?> r = (DefaultParameterValue<?>) XML.unmarshal(xml);
内容来源于网络,如有侵权,请联系作者删除!