/**
* Exports a single sheet to a file
*
* @param sheet
* @throws FactoryConfigurationError
* @throws XMLStreamException
* @throws UnsupportedEncodingException
* @throws FileNotFoundException
*/
private void export(final XSSFSheet sheet, final XMLStreamWriter out)
throws UnsupportedEncodingException, XMLStreamException, FactoryConfigurationError, FileNotFoundException {
boolean isFirst = true;
final Map<String, String> columns = new HashMap<String, String>();
final String sheetName = sheet.getSheetName();
System.out.print(sheetName);
out.writeStartElement("sheet");
out.writeAttribute("name", sheetName);
Iterator<Row> rowIterator = sheet.rowIterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
if (isFirst) {
isFirst = false;
this.writeFirstRow(row, out, columns);
} else {
this.writeRow(row, out, columns);
}
}
out.writeEndElement();
System.out.println("..");
}
java类javax.xml.stream.FactoryConfigurationError的实例源码
E2xCmdline.java 文件源码
项目:Excel2XML
阅读 21
收藏 0
点赞 0
评论 0
E2xCmdline.java 文件源码
项目:Excel2XML
阅读 25
收藏 0
点赞 0
评论 0
/**
* Parses an inputstream containin xlsx into an outputStream containing XML
*
* @param inputStream
* the source
* @param outputStream
* the result
* @throws IOException
* @throws XMLStreamException
*/
public void parse(final InputStream inputStream, final OutputStream outputStream)
throws IOException, XMLStreamException {
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
XMLStreamWriter out = this.getXMLWriter(outputStream);
out.writeStartDocument();
out.writeStartElement("workbook");
int sheetCount = workbook.getNumberOfSheets();
for (int i = 0; i < sheetCount; i++) {
final XSSFSheet sheet = workbook.getSheetAt(i);
try {
this.export(sheet, out);
} catch (UnsupportedEncodingException | FileNotFoundException | XMLStreamException
| FactoryConfigurationError e) {
e.printStackTrace();
}
}
out.writeEndElement();
out.writeEndDocument();
out.close();
workbook.close();
}
XmlDataSetProducer.java 文件源码
项目:morf
阅读 14
收藏 0
点赞 0
评论 0
/**
* @param inputStream The inputstream to read from
* @return A new pull parser
*/
private static XMLStreamReader openPullParser(InputStream inputStream) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Charsets.UTF_8));
Reader reader;
int version = Version2to4TransformingReader.readVersion(bufferedReader);
if (version == 2 || version == 3) {
reader = new Version2to4TransformingReader(bufferedReader, version);
} else {
reader = bufferedReader;
}
if (version > 4) {
throw new IllegalStateException("Unknown XML dataset format: "+version +" This dataset has been produced by a later version of Morf");
}
return XMLInputFactory.newFactory().createXMLStreamReader(reader);
} catch (XMLStreamException|FactoryConfigurationError e) {
throw new RuntimeException(e);
}
}
JaxbXmlMessageConverter.java 文件源码
项目:java-restify
阅读 16
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
@Override
public T read(HttpResponseMessage httpResponseMessage, Type expectedType) {
Class<T> expectedClassType = (Class<T>) expectedType;
JAXBContext context = contextOf(expectedClassType);
try {
Unmarshaller unmarshaller = context.createUnmarshaller();
StreamSource source = new StreamSource(httpResponseMessage.body());
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(source);
return expectedClassType.isAnnotationPresent(XmlRootElement.class) ? (T) unmarshaller.unmarshal(reader)
: unmarshaller.unmarshal(reader, expectedClassType).getValue();
} catch (JAXBException | XMLStreamException | FactoryConfigurationError e) {
throw new RestifyHttpMessageReadException("Error on try read xml message", e);
}
}
DownloadIlocateTask.java 文件源码
项目:JOSM-IndoorEditor
阅读 17
收藏 0
点赞 0
评论 0
protected DataSet getDataForFile(File f, final ProgressMonitor progressMonitor) throws FileNotFoundException, IOException, XMLStreamException, FactoryConfigurationError, JAXBException {
Main.debug("[DownloadIlocateTask.ZippedShpReader.getDataForFile] Calling MY getDataForFile");
if (f == null) {
return null;
} else if (!f.exists()) {
Main.warn("File does not exist: " + f.getPath());
return null;
} else {
Main.info("Parsing zipped shapefile " + f.getName());
FileInputStream in = new FileInputStream(f);
ProgressMonitor instance = null;
if (progressMonitor != null) {
instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
}
return ShpReader.parseDataSet(in, f, null, instance);
}
}
VespaRecordWriter.java 文件源码
项目:vespa
阅读 19
收藏 0
点赞 0
评论 0
private String findDocIdFromXml(String xml) {
try {
XMLEventReader eventReader = XMLInputFactory.newInstance().createXMLEventReader(new StringReader(xml));
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
if (event.getEventType() == XMLEvent.START_ELEMENT) {
StartElement element = event.asStartElement();
String elementName = element.getName().getLocalPart();
if (VespaDocumentOperation.Operation.valid(elementName)) {
return element.getAttributeByName(QName.valueOf("documentid")).getValue();
}
}
}
} catch (XMLStreamException | FactoryConfigurationError e) {
// as json dude does
return null;
}
return null;
}
XmlSource.java 文件源码
项目:beam
阅读 17
收藏 0
点赞 0
评论 0
private void setUpXMLParser(ReadableByteChannel channel, byte[] lookAhead) throws IOException {
try {
// We use Woodstox because the StAX implementation provided by OpenJDK reports
// character locations incorrectly. Note that Woodstox still currently reports *byte*
// locations incorrectly when parsing documents that contain multi-byte characters.
XMLInputFactory2 xmlInputFactory = (XMLInputFactory2) XMLInputFactory.newInstance();
this.parser = xmlInputFactory.createXMLStreamReader(
new SequenceInputStream(
new ByteArrayInputStream(lookAhead), Channels.newInputStream(channel)),
getCurrentSource().configuration.getCharset());
// Current offset should be the offset before reading the record element.
while (true) {
int event = parser.next();
if (event == XMLStreamConstants.START_ELEMENT) {
String localName = parser.getLocalName();
if (localName.equals(getCurrentSource().configuration.getRecordElement())) {
break;
}
}
}
} catch (FactoryConfigurationError | XMLStreamException e) {
throw new IOException(e);
}
}
JkImlGenerator.java 文件源码
项目:jerkar
阅读 16
收藏 0
点赞 0
评论 0
private String _generate() throws IOException, XMLStreamException, FactoryConfigurationError {
final ByteArrayOutputStream fos = new ByteArrayOutputStream();
writer = createWriter(fos);
writeHead();
writeOutput();
writeJdk();
writeContent();
writeOrderEntrySourceFolder();
final Set<Path> allPaths = new HashSet<>();
final Set<Path> allModules = new HashSet<>();
if (this.dependencyResolver != null) {
writeDependencies(dependencies, this.dependencyResolver, allPaths, allModules, false);
}
if (this.buildDependencyResolver != null) {
writeDependencies(this.buildDependencies, this.buildDependencyResolver, allPaths, allModules, true);
}
writeBuildProjectDependencies(allModules);
writeFoot();
writer.close();
return fos.toString(ENCODING);
}
TestNgReportBuilderCli.java 文件源码
项目:bootstraped-multi-test-results-report
阅读 15
收藏 0
点赞 0
评论 0
public static void main(String[] args)
throws FactoryConfigurationError, JAXBException, XMLStreamException, IOException {
List<String> xmlReports = new ArrayList<String>();
String[] extensions = {"xml"};
String xmlPath = System.getProperty("xmlPath");
String outputPath = System.getProperty("reportsOutputPath");
if (xmlPath == null || outputPath == null) {
throw new Error("xmlPath or reportsOutputPath variables have not been set");
}
Object[] files = FileUtils.listFiles(new File(xmlPath), extensions, false).toArray();
System.out.println("Found " + files.length + " xml files");
for (Object absFilePath : files) {
System.out.println("Found an xml: " + absFilePath);
xmlReports.add(((File) absFilePath).getAbsolutePath());
}
TestNgReportBuilder repo = new TestNgReportBuilder(xmlReports, outputPath);
repo.writeReportsOnDisk();
}
TestNgReportBuilder.java 文件源码
项目:bootstraped-multi-test-results-report
阅读 18
收藏 0
点赞 0
评论 0
public TestNgReportBuilder(List<String> xmlReports, String targetBuildPath)
throws JAXBException, XMLStreamException, FactoryConfigurationError, IOException {
testOverviewPath = targetBuildPath + "/";
classesSummaryPath = targetBuildPath + "/classes-summary/";
processedTestNgReports = new ArrayList<>();
JAXBContext cntx = JAXBContext.newInstance(TestngResultsModel.class);
Unmarshaller unm = cntx.createUnmarshaller();
for (String xml : xmlReports) {
InputStream inputStream = new FileInputStream(xml);
XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
TestngResultsModel ts = (TestngResultsModel) unm.unmarshal(xmlStream);
ts.postProcess();
processedTestNgReports.add(ts);
inputStream.close();
xmlStream.close();
}
}
XMLType.java 文件源码
项目:teiid
阅读 18
收藏 0
点赞 0
评论 0
private static XMLInputFactory createXMLInputFactory()
throws FactoryConfigurationError {
XMLInputFactory factory = XMLInputFactory.newInstance();
if (!SUPPORT_DTD) {
factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
//these next ones are somewhat redundant, we set them just in case the DTD support property is not respected
factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
factory.setXMLResolver(new XMLResolver() {
@Override
public Object resolveEntity(String arg0, String arg1, String arg2,
String arg3) throws XMLStreamException {
throw new XMLStreamException("Reading external entities is disabled"); //$NON-NLS-1$
}
});
}
return factory;
}
XmlUtil.java 文件源码
项目:FHIR-Server
阅读 30
收藏 0
点赞 0
评论 0
private static XMLOutputFactory getOrCreateOutputFactory() throws FactoryConfigurationError {
if (ourOutputFactory == null) {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
if (!ourHaveLoggedStaxImplementation) {
logStaxImplementation(outputFactory.getClass());
}
/*
* Note that these properties are Woodstox specific and they cause a crash in environments where SJSXP is
* being used (e.g. glassfish) so we don't set them there.
*/
try {
Class.forName("com.ctc.wstx.stax.WstxOutputFactory");
if (outputFactory instanceof WstxOutputFactory) {
outputFactory.setProperty(XMLOutputFactory2.P_TEXT_ESCAPER, new MyEscaper());
}
} catch (ClassNotFoundException e) {
ourLog.debug("WstxOutputFactory (Woodstox) not found on classpath");
}
ourOutputFactory = outputFactory;
}
return ourOutputFactory;
}
AtomEntryProducerTest.java 文件源码
项目:olingo-odata2
阅读 19
收藏 0
点赞 0
评论 0
/**
* Test serialization of empty syndication title property. EmployeeName is set to NULL after the update (which is
* allowed because EmployeeName has default Nullable behavior which is true).
* Write of an empty atom title tag is allowed within RFC4287 (http://tools.ietf.org/html/rfc4287#section-4.2.14).
*/
@Test
public void serializeEmployeeWithNullSyndicationTitleProperty() throws IOException, XpathException, SAXException,
XMLStreamException, FactoryConfigurationError, ODataException {
AtomEntityProvider ser = createAtomEntityProvider();
EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
employeeData.put("EmployeeName", null);
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"), employeeData,
properties);
String xmlString = verifyResponse(response);
assertXpathExists("/a:entry/a:title", xmlString);
assertXpathEvaluatesTo("", "/a:entry/a:title", xmlString);
assertXpathExists("/a:entry", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString(), "/a:entry/@xml:base", xmlString);
assertXpathExists("/a:entry/a:content", xmlString);
assertXpathEvaluatesTo("Employees('1')/$value", "/a:entry/a:content/@src", xmlString);
assertXpathExists("/a:entry/m:properties", xmlString);
}
AtomEntryProducerTest.java 文件源码
项目:olingo-odata2
阅读 21
收藏 0
点赞 0
评论 0
@Test
public void serializeEmployeeAndCheckOrderOfPropertyTags() throws IOException, XpathException, SAXException,
XMLStreamException, FactoryConfigurationError, ODataException {
AtomEntityProvider ser = createAtomEntityProvider();
EntityProviderWriteProperties properties =
EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
EdmEntitySet employeeEntitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
ODataResponse response = ser.writeEntry(employeeEntitySet, employeeData, properties);
String xmlString = verifyResponse(response);
// log.debug(xmlString);
assertXpathExists("/a:entry", xmlString);
assertXpathExists("/a:entry/a:content", xmlString);
// verify properties
assertXpathExists("/a:entry/m:properties", xmlString);
assertXpathEvaluatesTo("9", "count(/a:entry/m:properties/*)", xmlString);
// verify order of tags
List<String> expectedPropertyNamesFromEdm = employeeEntitySet.getEntityType().getPropertyNames();
verifyTagOrdering(xmlString, expectedPropertyNamesFromEdm.toArray(new String[0]));
}
AtomEntryProducerTest.java 文件源码
项目:olingo-odata2
阅读 19
收藏 0
点赞 0
评论 0
@Test
public void serializeAtomEntry() throws IOException, XpathException, SAXException, XMLStreamException,
FactoryConfigurationError, ODataException {
final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"), roomData, properties);
String xmlString = verifyResponse(response);
assertXpathExists("/a:entry", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString(), "/a:entry/@xml:base", xmlString);
assertXpathExists("/a:entry/a:content", xmlString);
assertXpathEvaluatesTo(ContentType.APPLICATION_XML.toString(), "/a:entry/a:content/@type", xmlString);
assertXpathExists("/a:entry/a:content/m:properties", xmlString);
}
AtomEntryProducerTest.java 文件源码
项目:olingo-odata2
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void serializeWithValueEncoding() throws IOException, XpathException, SAXException, XMLStreamException,
FactoryConfigurationError, ODataException {
photoData.put("Type", "< Ö >");
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos"), photoData,
DEFAULT_PROPERTIES);
String xmlString = verifyResponse(response);
assertXpathExists("/a:entry", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString(), "/a:entry/@xml:base", xmlString);
assertXpathExists("/a:entry/a:id", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString() + "Container2.Photos(Id=1,Type='%3C%20%C3%96%20%3E')",
"/a:entry/a:id/text()", xmlString);
assertXpathEvaluatesTo("Container2.Photos(Id=1,Type='%3C%20%C3%96%20%3E')", "/a:entry/a:link/@href", xmlString);
}
AtomEntryProducerTest.java 文件源码
项目:olingo-odata2
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void serializeETagEncoding() throws IOException, XpathException, SAXException, XMLStreamException,
FactoryConfigurationError, ODataException {
Edm edm = MockFacade.getMockEdm();
EdmTyped roomIdProperty = edm.getEntityType("RefScenario", "Room").getProperty("Id");
EdmFacets facets = mock(EdmFacets.class);
when(facets.getConcurrencyMode()).thenReturn(EdmConcurrencyMode.Fixed);
when(facets.getMaxLength()).thenReturn(3);
when(((EdmProperty) roomIdProperty).getFacets()).thenReturn(facets);
roomData.put("Id", "<\">");
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response =
ser.writeEntry(edm.getDefaultEntityContainer().getEntitySet("Rooms"), roomData, DEFAULT_PROPERTIES);
assertNotNull(response);
assertNotNull(response.getEntity());
assertNull("EntityProvider should not set content header", response.getContentHeader());
assertEquals("W/\"<\">.3\"", response.getETag());
String xmlString = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertXpathExists("/a:entry", xmlString);
assertXpathExists("/a:entry/@m:etag", xmlString);
assertXpathEvaluatesTo("W/\"<\">.3\"", "/a:entry/@m:etag", xmlString);
}
AtomEntryProducerTest.java 文件源码
项目:olingo-odata2
阅读 16
收藏 0
点赞 0
评论 0
@Test
public void serializeAtomMediaResourceLinks() throws IOException, XpathException, SAXException, XMLStreamException,
FactoryConfigurationError, ODataException {
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"), employeeData,
DEFAULT_PROPERTIES);
String xmlString = verifyResponse(response);
String rel = Edm.NAMESPACE_REL_2007_08 + "ne_Manager";
assertXpathExists("/a:entry/a:link[@href=\"Employees('1')/ne_Manager\"]", xmlString);
assertXpathExists("/a:entry/a:link[@rel='" + rel + "']", xmlString);
assertXpathExists("/a:entry/a:link[@type='application/atom+xml;type=entry']", xmlString);
assertXpathExists("/a:entry/a:link[@title='ne_Manager']", xmlString);
}
TelldusLiveDeviceController.java 文件源码
项目:openhab2-addons
阅读 18
收藏 0
点赞 0
评论 0
private <T> T innerCallRest(String uri, Class<T> response) throws InterruptedException, ExecutionException,
TimeoutException, JAXBException, FactoryConfigurationError, XMLStreamException {
Future<Response> future = client.prepareGet(uri).execute();
Response resp = future.get(REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
// TelldusLiveHandler.logger.info("Devices" + resp.getResponseBody());
JAXBContext jc = JAXBContext.newInstance(response);
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLStreamReader xsr = xif.createXMLStreamReader(resp.getResponseBodyAsStream());
// xsr = new PropertyRenamerDelegate(xsr);
@SuppressWarnings("unchecked")
T obj = (T) jc.createUnmarshaller().unmarshal(xsr);
if (logger.isTraceEnabled()) {
logger.trace("Request [{}] Response:{}", uri, resp.getResponseBody());
}
return obj;
}
PackagePrepareSystemScopeMojo.java 文件源码
项目:maven-tools
阅读 17
收藏 0
点赞 0
评论 0
private void aggregateDependencies(List<MavenProject> mavenProjects) {
dependencySystemPathMap = new HashMap<>();
for (MavenProject mavenProject : mavenProjects) {
String packaging = mavenProject.getPackaging();
// CAPP projects are ignored.
if (packaging == null || !MavenConstants.CAPP_PACKAGING.equals(packaging)) {
try {
dependencySystemPathMap.putAll(PackagePrepareUtils.getArtifactsSystemPathMap(mavenProject));
} catch (FactoryConfigurationError | Exception e) {
// Can proceed even if this is reached
log.warn("Failed to retrieve dependencies from project: " + mavenProject.getGroupId() + ":"
+ mavenProject.getArtifactId() + ":" + mavenProject.getVersion(), e);
}
}
}
if (isDebugEnabled) {
Iterator<Entry<String, String>> dependencyIterator = dependencySystemPathMap.entrySet().iterator();
while (dependencyIterator.hasNext()) {
log.debug("Identified system path of: " + dependencyIterator.next().getKey());
}
}
}
MavenReleasePrePrepareMojo.java 文件源码
项目:maven-tools
阅读 18
收藏 0
点赞 0
评论 0
/**
* set Registry artifact version in artifact.xml file
*
* @param prop
* properties in release.properties file
* @param repoType
* type of the repository
* @param artifactXml
* @throws FactoryConfigurationError
* @throws Exception
*/
private void setRegArtifactVersion(Properties prop, String repoType, File artifactXml)
throws FactoryConfigurationError,
Exception {
File pomFile = new File(artifactXml.getParent() + File.separator + POM_XML);
MavenProject mavenProject=getMavenProject(pomFile);
String releaseVersion = prop.getProperty(PROJECT + repoType + "."+ mavenProject.getGroupId() + ":" + mavenProject.getArtifactId());
GeneralProjectArtifact projectArtifact = new GeneralProjectArtifact();
projectArtifact.fromFile(artifactXml);
for (RegistryArtifact artifact : projectArtifact.getAllESBArtifacts()) {
if (artifact.getVersion() != null && artifact.getType() != null) {
if (releaseVersion != null) {
artifact.setVersion(releaseVersion);
}
}
}
projectArtifact.toFile();
}
MavenReleasePrePrepareMojo.java 文件源码
项目:maven-tools
阅读 17
收藏 0
点赞 0
评论 0
/**
* set ESB artifact version in artifact.xml file
*
* @param prop
* properties in release.properties file
* @param repoType
* type of the repository
* @param artifactXml
* @throws FactoryConfigurationError
* @throws Exception
*/
private void setESBArtifactVersion(Properties prop, String repoType, File artifactXml)
throws FactoryConfigurationError,
Exception {
File pomFile = new File(artifactXml.getParent() + File.separator + POM_XML);
MavenProject mavenProject=getMavenProject(pomFile);
String releaseVersion = prop.getProperty(PROJECT + repoType + "."+mavenProject.getGroupId() + ":" + mavenProject.getArtifactId());
ESBProjectArtifact projectArtifact = new ESBProjectArtifact();
projectArtifact.fromFile(artifactXml);
for (ESBArtifact artifact : projectArtifact.getAllESBArtifacts()) {
if (artifact.getVersion() != null && artifact.getType() != null) {
if (releaseVersion != null) {
artifact.setVersion(releaseVersion);
}
}
}
projectArtifact.toFile();
}
CarbonUIPOMGenMojo.java 文件源码
项目:maven-tools
阅读 16
收藏 0
点赞 0
评论 0
protected BundlesDataInfo getBundlesDataInfo(File targetProjectLocation, Artifact artifact)throws FactoryConfigurationError {
if (bundlesDataInfo==null) {
try {
bundlesDataInfo = new BundlesDataInfo();
bundlesDataInfo.setProjects(getProjectMappings());
List<String> artifactProjects = getArtifactProjects();
for (String artifactProject : artifactProjects) {
String[] artifactProjectData = artifactProject.split(":");
if (artifactProjectData.length==2 && artifactProjectData[0].equals(artifact.getName())){
String[] projectNames = artifactProjectData[1].split(",");
for (String projectName : projectNames) {
bundlesDataInfo.addProjectToList(projectName, null);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return bundlesDataInfo;
}
AbstractXmlDocMediaTypeResolver.java 文件源码
项目:developer-studio
阅读 16
收藏 0
点赞 0
评论 0
protected boolean isDocumentTag(InputStream dataStream, String tagName) throws FactoryConfigurationError {
try {
String content = FileUtils.getContentAsString(dataStream);
if (content != null) {
content = content.toLowerCase();
if (content.contains("<html") && content.contains("</html>")) {
if (tagName.equals("html")) {
return true;
}
}
dataStream = new ByteArrayInputStream(content.getBytes());
}
OMElement documentElement = getXmlDoc(dataStream);
String localName = documentElement.getLocalName();
return localName.equalsIgnoreCase(tagName);
} catch (Exception e) {
return false;
}
}
AxisService2WSDL20.java 文件源码
项目:wso2-axis2
阅读 14
收藏 0
点赞 0
评论 0
private void addPoliciesToDescriptionElement(List policies,
OMElement descriptionElement) throws XMLStreamException,
FactoryConfigurationError {
for (int i = 0; i < policies.size(); i++) {
Policy policy = (Policy) policies.get(i);
OMElement policyElement = PolicyUtil.getPolicyComponentAsOMElement(
policy, filter);
OMNode firstChild = descriptionElement.getFirstOMChild();
if (firstChild != null) {
firstChild.insertSiblingBefore(policyElement);
} else {
descriptionElement.addChild(policyElement);
}
}
}
PolicyUtil.java 文件源码
项目:wso2-axis2
阅读 17
收藏 0
点赞 0
评论 0
public static OMElement getPolicyComponentAsOMElement(
PolicyComponent policyComponent,
ExternalPolicySerializer externalPolicySerializer)
throws XMLStreamException, FactoryConfigurationError {
if (policyComponent instanceof Policy) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
externalPolicySerializer.serialize((Policy) policyComponent, baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos
.toByteArray());
return (OMElement) XMLUtils.toOM(bais);
} else {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement elem = fac.createOMElement(Constants.ELEM_POLICY_REF,
Constants.URI_POLICY_NS, Constants.ATTR_WSP);
elem.addAttribute(Constants.ATTR_URI,
((PolicyReference) policyComponent).getURI(), null);
return elem;
}
}
FeatureCompletenessChecker.java 文件源码
项目:InSpider
阅读 17
收藏 0
点赞 0
评论 0
private List<Resource> createGetFeatureResourcesAllDatasets()
throws JaxenException, XMLStreamException,
FactoryConfigurationError, IOException {
List<Resource> getFeatureResourcesAllDatasets = new ArrayList<Resource>();
List<Dataset> datasets = managerDao.getAllDatasets();
int quantityDatasetsLoadedInInspireSchema = 0;
for (Iterator<Dataset> datasetIterator = datasets.iterator(); datasetIterator.hasNext();) {
Dataset dataset = (Dataset) datasetIterator.next();
EtlJob job = managerDao.getLastSuccessfullImportJob(dataset.getBronhouder(), dataset.getDatasetType(), dataset.getUuid());
if(job != null){
String fileCacheDir = null;//fileCache.getFiledir(job);
String file = null;//fileCache.getFilename(job);
Resource cachedResource = new FileSystemResource(fileCacheDir + System.getProperty("file.separator") + file);
logger.debug("Adding cachedResource(" + quantityDatasetsLoadedInInspireSchema + ") " + "\"" + cachedResource.getDescription() + "\" to the cached-resources-list.");
getFeatureResourcesAllDatasets.add(cachedResource);
quantityDatasetsLoadedInInspireSchema++;
}
}
logger.debug("Quantity of datasets that resulted in features in inspire schema:" + quantityDatasetsLoadedInInspireSchema);
return getFeatureResourcesAllDatasets;
}
XMLCorpusReader.java 文件源码
项目:pos-tagger
阅读 17
收藏 0
点赞 0
评论 0
public static List<TaggedSentence> getTaggedSentences(String xmlCorpusPath, int minNumberOfTokens) throws XMLStreamException, FactoryConfigurationError,
FileNotFoundException {
List<TaggedSentence> taggedSentences = new ArrayList<>();
XMLEventReader xmlEventReader = XMLInputFactory.newInstance().createXMLEventReader(new FileInputStream(xmlCorpusPath));
while (xmlEventReader.hasNext()) {
XMLEvent event = xmlEventReader.nextEvent();
if (event.isStartElement() && "source".equals(event.asStartElement().getName().getLocalPart())) {
String sentence = extractSentence(xmlEventReader);
List<StringTaggedToken> taggedTokens = extractTaggedTokens(xmlEventReader);
if (!allTagsRecognized(taggedTokens) || (taggedTokens.size() < minNumberOfTokens)) {
continue;
}
TaggedSentence taggedSentence = createTaggedSentence(sentence, taggedTokens);
taggedSentences.add(taggedSentence);
}
}
return taggedSentences;
}
MubiListsScraper.java 文件源码
项目:mubi-lists-scraper
阅读 18
收藏 0
点赞 0
评论 0
public static void main(String ars[]) throws XMLStreamException,
FactoryConfigurationError, IOException {
for (int page = 1; page <= 10; page++) {
System.out.println("Fetching page " + page);
URL url = new URL(MUBI_LISTS_BASE_URL + "&page=" + page);
List<MubiListRef> lists = MubiListsReader.getInstance()
.readMubiLists(url);
for (MubiListRef list : lists) {
System.out.println(" Fetching list " + list.getTitle());
List<MubiFilmRef> filmList = MubiListsReader.getInstance()
.readMubiFilmList(
new URL(MUBI_BASE_URL + list.getUrl()));
list.addFilms(filmList);
}
File outfile = new File("output", "mubi-lists-page-" + String.format("%04d", page) + ".json");
System.out.println("Writing "+ outfile.getName());
mapper.writeValue(outfile,
lists);
}
}
XMLStreamReaderUtils.java 文件源码
项目:bag-etl
阅读 19
收藏 0
点赞 0
评论 0
public static XMLStreamReader getXMLStreamReader(InputStream is) throws XMLStreamException, FactoryConfigurationError
{
//return XMLInputFactory.newInstance().createXMLStreamReader(is);
return new StreamReaderDelegate(XMLInputFactory.newInstance().createXMLStreamReader(is))
{
public int next() throws XMLStreamException
{
while (true)
{
int event = super.next();
switch (event)
{
case XMLStreamConstants.COMMENT:
case XMLStreamConstants.PROCESSING_INSTRUCTION:
continue;
default:
return event;
}
}
}
};
}