@Test public void testAllSamples() throws Exception { File cobolDir = new File(COBOL_SAMPLES_DIR); for (File cobolFile : cobolDir.listFiles()) { if (cobolFile.isFile()) { _log.debug("Translating " + cobolFile); String name = cobolFile.getName().toLowerCase(); configProps.put(Cob2XsdConfig.ADD_LEGSTAR_ANNOTATIONS, Boolean.toString(true)); configProps.put( Cob2XsdConfig.ELEMENT_NAMES_START_WITH_UPPERCASE, Boolean.toString(true)); configProps.put(Cob2XsdConfig.QUOTE_IS_QUOTE, Boolean.toString(false)); Cob2XsdIO translator = new Cob2XsdIO(new Cob2XsdConfig( configProps)); File custmXslt = new File(XSLT_SAMPLES_DIR, name + ".xsl"); File xsdFile = translator.translate(cobolFile, "ISO-8859-1", tempDir, "http: if (_log.isDebugEnabled()) { _log.debug("Result:\n" + FileUtils.readFileToString(xsdFile)); } File xsdRefFile = new File(XSD_REFERENCES_DIR, name.toLowerCase() + ".xsd"); if (CREATE_REFERENCES) { FileUtils.copyFile(xsdFile, xsdRefFile); } else { Document result = getXMLSchemaAsDoc(xsdFile); Document expected = getXMLSchemaAsDoc(xsdRefFile); compare(xsdFile.getName(), expected, result); } xsdFile.deleteOnExit(); } } }
public File translate(final File cobolFile, final String cobolFileEncoding, final File target, final String targetNamespacePrefix, final String xsltFileName) throws RecognizerException, XsdGenerationException { try { if (_log.isDebugEnabled()) { _log.debug("Translating COBOL file: " + cobolFile); } checkCobolSourceFile(cobolFile); checkTarget(target); String baseName = FilenameUtils.getBaseName( cobolFile.getAbsolutePath()).toLowerCase(); Reader cobolReader = cobolFileEncoding == null ? new InputStreamReader( new FileInputStream(cobolFile)) : new InputStreamReader( new FileInputStream(cobolFile), cobolFileEncoding); String xsdString = translate(cobolReader, getUniqueTargetNamespace(targetNamespacePrefix, baseName), xsltFileName); File xsdFile = null; if (target.isDirectory()) { String xsdFileName = cobolFile.getName() + ".xsd"; xsdFile = new File(target, xsdFileName); } else { xsdFile = target; } FileUtils.writeStringToFile(xsdFile, xsdString, getConfig() .getXsdEncoding()); if (_log.isDebugEnabled()) { _log.debug("Created XML schema file: " + xsdFile); } return xsdFile; } catch (IOException e) { throw (new XsdGenerationException(e)); } }
Cob2XsdIO extends Cob2Xsd { public File translate(final File cobolFile, final String cobolFileEncoding, final File target, final String targetNamespacePrefix, final String xsltFileName) throws RecognizerException, XsdGenerationException { try { if (_log.isDebugEnabled()) { _log.debug("Translating COBOL file: " + cobolFile); } checkCobolSourceFile(cobolFile); checkTarget(target); String baseName = FilenameUtils.getBaseName( cobolFile.getAbsolutePath()).toLowerCase(); Reader cobolReader = cobolFileEncoding == null ? new InputStreamReader( new FileInputStream(cobolFile)) : new InputStreamReader( new FileInputStream(cobolFile), cobolFileEncoding); String xsdString = translate(cobolReader, getUniqueTargetNamespace(targetNamespacePrefix, baseName), xsltFileName); File xsdFile = null; if (target.isDirectory()) { String xsdFileName = cobolFile.getName() + ".xsd"; xsdFile = new File(target, xsdFileName); } else { xsdFile = target; } FileUtils.writeStringToFile(xsdFile, xsdString, getConfig() .getXsdEncoding()); if (_log.isDebugEnabled()) { _log.debug("Created XML schema file: " + xsdFile); } return xsdFile; } catch (IOException e) { throw (new XsdGenerationException(e)); } } }
Cob2XsdIO extends Cob2Xsd { public File translate(final File cobolFile, final String cobolFileEncoding, final File target, final String targetNamespacePrefix, final String xsltFileName) throws RecognizerException, XsdGenerationException { try { if (_log.isDebugEnabled()) { _log.debug("Translating COBOL file: " + cobolFile); } checkCobolSourceFile(cobolFile); checkTarget(target); String baseName = FilenameUtils.getBaseName( cobolFile.getAbsolutePath()).toLowerCase(); Reader cobolReader = cobolFileEncoding == null ? new InputStreamReader( new FileInputStream(cobolFile)) : new InputStreamReader( new FileInputStream(cobolFile), cobolFileEncoding); String xsdString = translate(cobolReader, getUniqueTargetNamespace(targetNamespacePrefix, baseName), xsltFileName); File xsdFile = null; if (target.isDirectory()) { String xsdFileName = cobolFile.getName() + ".xsd"; xsdFile = new File(target, xsdFileName); } else { xsdFile = target; } FileUtils.writeStringToFile(xsdFile, xsdString, getConfig() .getXsdEncoding()); if (_log.isDebugEnabled()) { _log.debug("Created XML schema file: " + xsdFile); } return xsdFile; } catch (IOException e) { throw (new XsdGenerationException(e)); } } Cob2XsdIO(final Cob2XsdConfig config); }
Cob2XsdIO extends Cob2Xsd { public File translate(final File cobolFile, final String cobolFileEncoding, final File target, final String targetNamespacePrefix, final String xsltFileName) throws RecognizerException, XsdGenerationException { try { if (_log.isDebugEnabled()) { _log.debug("Translating COBOL file: " + cobolFile); } checkCobolSourceFile(cobolFile); checkTarget(target); String baseName = FilenameUtils.getBaseName( cobolFile.getAbsolutePath()).toLowerCase(); Reader cobolReader = cobolFileEncoding == null ? new InputStreamReader( new FileInputStream(cobolFile)) : new InputStreamReader( new FileInputStream(cobolFile), cobolFileEncoding); String xsdString = translate(cobolReader, getUniqueTargetNamespace(targetNamespacePrefix, baseName), xsltFileName); File xsdFile = null; if (target.isDirectory()) { String xsdFileName = cobolFile.getName() + ".xsd"; xsdFile = new File(target, xsdFileName); } else { xsdFile = target; } FileUtils.writeStringToFile(xsdFile, xsdString, getConfig() .getXsdEncoding()); if (_log.isDebugEnabled()) { _log.debug("Created XML schema file: " + xsdFile); } return xsdFile; } catch (IOException e) { throw (new XsdGenerationException(e)); } } Cob2XsdIO(final Cob2XsdConfig config); File translate(final File cobolFile, final String cobolFileEncoding,
            final File target, final String targetNamespacePrefix,
            final String xsltFileName); }
Cob2XsdIO extends Cob2Xsd { public File translate(final File cobolFile, final String cobolFileEncoding, final File target, final String targetNamespacePrefix, final String xsltFileName) throws RecognizerException, XsdGenerationException { try { if (_log.isDebugEnabled()) { _log.debug("Translating COBOL file: " + cobolFile); } checkCobolSourceFile(cobolFile); checkTarget(target); String baseName = FilenameUtils.getBaseName( cobolFile.getAbsolutePath()).toLowerCase(); Reader cobolReader = cobolFileEncoding == null ? new InputStreamReader( new FileInputStream(cobolFile)) : new InputStreamReader( new FileInputStream(cobolFile), cobolFileEncoding); String xsdString = translate(cobolReader, getUniqueTargetNamespace(targetNamespacePrefix, baseName), xsltFileName); File xsdFile = null; if (target.isDirectory()) { String xsdFileName = cobolFile.getName() + ".xsd"; xsdFile = new File(target, xsdFileName); } else { xsdFile = target; } FileUtils.writeStringToFile(xsdFile, xsdString, getConfig() .getXsdEncoding()); if (_log.isDebugEnabled()) { _log.debug("Created XML schema file: " + xsdFile); } return xsdFile; } catch (IOException e) { throw (new XsdGenerationException(e)); } } Cob2XsdIO(final Cob2XsdConfig config); File translate(final File cobolFile, final String cobolFileEncoding,
            final File target, final String targetNamespacePrefix,
            final String xsltFileName);  }