Java 类javax.xml.stream.FactoryConfigurationError 实例源码

项目:Excel2XML    文件:E2xCmdline.java   
/**
 * 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("..");
}
项目:Excel2XML    文件:E2xCmdline.java   
/**
 * 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();
}
项目:morf    文件:XmlDataSetProducer.java   
/**
 * @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);
  }
}
项目:java-restify    文件:JaxbXmlMessageConverter.java   
@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);
    }
}
项目:JOSM-IndoorEditor    文件:DownloadIlocateTask.java   
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);
    }
}
项目:vespa    文件:VespaRecordWriter.java   
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;
}
项目:beam    文件:XmlSource.java   
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);
  }
}
项目:jerkar    文件:JkImlGenerator.java   
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);
}
项目:bootstraped-multi-test-results-report    文件:TestNgReportBuilderCli.java   
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();
}
项目:bootstraped-multi-test-results-report    文件:TestNgReportBuilder.java   
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();
    }
}
项目:teiid    文件:XMLType.java   
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;
}
项目:FHIR-Server    文件:XmlUtil.java   
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;
}
项目:olingo-odata2    文件:AtomEntryProducerTest.java   
/**
 * 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);
}
项目:olingo-odata2    文件:AtomEntryProducerTest.java   
@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]));
}
项目:olingo-odata2    文件:AtomEntryProducerTest.java   
@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);
}
项目:olingo-odata2    文件:AtomEntryProducerTest.java   
@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);
}
项目:olingo-odata2    文件:AtomEntryProducerTest.java   
@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);
}
项目:olingo-odata2    文件:AtomEntryProducerTest.java   
@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);
}
项目:openhab2-addons    文件:TelldusLiveDeviceController.java   
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;
}
项目:maven-tools    文件:PackagePrepareSystemScopeMojo.java   
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());
        }
    }
}
项目:maven-tools    文件:MavenReleasePrePrepareMojo.java   
/**
 * 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();
}
项目:maven-tools    文件:MavenReleasePrePrepareMojo.java   
/**
 * 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();
}
项目:maven-tools    文件:CarbonUIPOMGenMojo.java   
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;
}
项目:developer-studio    文件:AbstractXmlDocMediaTypeResolver.java   
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;
    }
}
项目:wso2-axis2    文件:AxisService2WSDL20.java   
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);
        }
    }
}
项目:wso2-axis2    文件:PolicyUtil.java   
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;
    }
}
项目:InSpider    文件:FeatureCompletenessChecker.java   
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;
}
项目:pos-tagger    文件:XMLCorpusReader.java   
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;
}
项目:mubi-lists-scraper    文件:MubiListsScraper.java   
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);
    }
}
项目:bag-etl    文件:XMLStreamReaderUtils.java   
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;
                }
            }
        }
    };
}
项目:fx-experience    文件:XmlHelperTest.java   
@Test
public void readIntAttribute() throws XMLStreamException, FactoryConfigurationError, IOException {
  URL url = XmlHelperTest.class.getResource("/xml/kb-layout.xml");
  XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(url.openStream());
  reader.next();
  reader.require(XMLStreamConstants.START_ELEMENT, null, XmlHelper.KEYBOARD);

  assertEquals(Integer.valueOf(40),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_WIDTH).orElse(-1));
  assertEquals(Integer.valueOf(30),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_HEIGHT).orElse(-1));
  assertEquals(Integer.valueOf(0),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_H_GAP).orElse(-1));
  assertEquals(Integer.valueOf(0),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_V_GAP).orElse(-1));
  assertNull(XmlHelper.readIntAttribute(reader, "verticalGapX").orElse(null));

  assertEquals(40, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_WIDTH, 1));
  assertEquals(30, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_HEIGHT, 1));
  assertEquals(0, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_H_GAP, 1));
  assertEquals(0, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_V_GAP, 1));
  assertEquals(1, XmlHelper.readIntAttribute(reader, "verticalGapX", 1));
  assertEquals(1, XmlHelper.readIntAttribute(reader, "", 1));
  assertEquals(1, XmlHelper.readIntAttribute(reader, null, 1));
}
项目:fx-experience    文件:XmlHelperTest.java   
@Test
public void readBooleanAttribute()
    throws XMLStreamException, FactoryConfigurationError, IOException {
  URL url = XmlHelperTest.class.getResource("/xml/kb-layout.xml");
  XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(url.openStream());
  reader.next();
  reader.require(XMLStreamConstants.START_ELEMENT, null, XmlHelper.KEYBOARD);

  assertFalse(XmlHelper.readBooleanAttribute(reader, XmlHelper.ATTR_REPEATABLE, false));
  assertFalse(XmlHelper.readBooleanAttribute(reader, "", false));

  while (reader.hasNext()) {
    reader.next();
    if (!reader.isStartElement() || !XmlHelper.KEY.equals(reader.getLocalName())) {
      continue;
    }
    if (32 == XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_CODES, -1)) {
      assertTrue(XmlHelper.readBooleanAttribute(reader, XmlHelper.ATTR_REPEATABLE, false));
      assertTrue(XmlHelper.readBooleanAttribute(reader, XmlHelper.ATTR_MOVABLE, false));
    }

    if (-1 == XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_CODES, 0)) {
      assertTrue(XmlHelper.readBooleanAttribute(reader, XmlHelper.ATTR_STICKY, false));
    }
  }
}
项目:jruby-cxf    文件:SourceType.java   
protected void write(Source object, XMLStreamWriter writer) throws FactoryConfigurationError,
    XMLStreamException, DatabindingException {
    if (object == null) {
        return;
    }

    if (object instanceof DOMSource) {
        DOMSource ds = (DOMSource)object;

        Element element = null;
        if (ds.getNode() instanceof Element) {
            element = (Element)ds.getNode();
        } else if (ds.getNode() instanceof Document) {
            element = ((Document)ds.getNode()).getDocumentElement();
        } else {
            throw new DatabindingException("Node type " + ds.getNode().getClass()
                                           + " was not understood.");
        }

        StaxUtils.writeElement(element, writer, false);
    } else {
        StaxUtils.copy(object, writer);
    }
}
项目:EvalBench    文件:XMLJournal.java   
private void open(File file) throws XMLStreamException,
        FactoryConfigurationError, FileNotFoundException {
    // open writer
    FileOutputStream fos = new FileOutputStream(file);
    writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fos,
            "UTF-8");

    // start document
    writer.setDefaultNamespace(URI_NS);
    writer.writeStartDocument("UTF-8", "1.0");
    writer.writeCharacters("\n");
    writer.writeStartElement(URI_NS, "journal");
    if (URI_NS.length() > 0) {
        writer.writeDefaultNamespace(URI_NS);
    }
    writer.writeCharacters("\n");

    writer.writeStartElement(URI_NS, "participant");
    writer.writeCharacters(participantId);
    writer.writeEndElement();
}
项目:EvalBench    文件:XMLInsightJournal.java   
private void open(File file) throws FileNotFoundException,
        XMLStreamException, FactoryConfigurationError,
        DatatypeConfigurationException {
    // open writer
    FileOutputStream fos = new FileOutputStream(file);
    writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fos,
            "UTF-8");

    // start document
    writer.setDefaultNamespace(URI_NS);
    writer.writeStartDocument("UTF-8", "1.0");
    writer.writeCharacters("\n");
    writer.writeStartElement(URI_NS, "insights");
    if (URI_NS.length() > 0) {
        writer.writeDefaultNamespace(URI_NS);
    }
    writer.writeNamespace("html", URI_NS_XHTML);
    writer.writeCharacters("\n");
    // writer.writeStartElement(URI_NS, "participant");
    // writer.writeCharacters(participantId);
    // writer.writeEndElement();

    // reset index
    index = 0;
    timeConv = new XmlCalendarConverter();
}
项目:cloud-odata-java    文件:AtomEntryProducerTest.java   
/**
 * 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);
}
项目:cloud-odata-java    文件:AtomEntryProducerTest.java   
@Test
public void serializeEmployeeAndCheckOrderOfPropertyTags() throws IOException, XpathException, SAXException, XMLStreamException, FactoryConfigurationError, ODataException {
  AtomEntityProvider ser = createAtomEntityProvider();
  EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(BASE_URI).mediaResourceMimeType("abc").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]));
}
项目:cloud-odata-java    文件:AtomEntryProducerTest.java   
@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());
  assertEquals(ContentType.APPLICATION_ATOM_XML_ENTRY_CS_UTF_8.toContentTypeString(), 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);
}
项目:dp-mzml    文件:MzMLStAXParser.java   
public FromXMLStreamIterator() throws XMLStreamException {
    XMLInputFactory fac = XMLInputFactory.newInstance();
    try { 
        this.xr = fac.createXMLStreamReader(Files.newInputStream(MzMLStAXParser.this.xml, StandardOpenOption.READ));
    } catch (FactoryConfigurationError | IOException e) {
        LOGGER.log(Level.ERROR, e.getMessage());
        System.exit(-1);
    }
    if (!this.moveToNextSpectrum()){
        LOGGER.log(Level.WARN,  "no spectrum found in mzml file");
    }
}
项目:dp-mzml    文件:MzMLStAXParser.java   
private T getNextSpectrumFromSeekable() {
    FromXMLStreamBuilder<T> spectrumBuilder = null;
    try {
        InputStream is = Channels.newInputStream(this.seekable);
        XMLStreamReader xr = XMLInputFactory.newInstance()
            .createXMLStreamReader(is);

        while (xr.hasNext()) {
            xr.next();

            if (spectrumBuilder != null) {
                spectrumBuilder.accept(xr);
            }

            if(xr.getEventType() == XMLStreamReader.START_ELEMENT){
                if(xr.getLocalName().equals("spectrum")) {
                    spectrumBuilder = this.factory.create(this.xml.toString(), xr);
                } else if( xr.getLocalName().equals("referenceableParamGroupRef")) {
                    LOGGER.log(Level.WARN, "Random access to spectra will not parse referenceable params");
                }
            } else if(xr.getEventType() == XMLStreamReader.END_ELEMENT) {
                if(xr.getLocalName().equals("spectrum")) {
                    return spectrumBuilder.build();
                }                   
            }
        }
    } catch (XMLStreamException | FactoryConfigurationError e) {
        LOGGER.log(Level.ERROR, e.toString());
    } 

    return null;
}