new org.jibx.binding.model.ValidationContext(new DummyClassLocator()); BindingElement binding = BindingElement.readBinding(url.openStream(), name, null, true, vctx); binding.setBaseUrl(url); vctx.setBindingRoot(binding); if (vctx.getProblems().size() > 0) { reportBindingProblems(vctx, handler); if (vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) { throw new JiBXException("Errors in binding");
/** * Populate the mapping directory from a supplied list of root bindings. This uses a visitor to analyze the * bindings, building the detail information to be used during the actual generation process. * * @param bindings */ public void populate(List bindings) { // analyze all the bindings AnalysisVisitor visitor = new AnalysisVisitor(m_context); for (Iterator iter = bindings.iterator(); iter.hasNext();) { m_context.tourTree((BindingElement)iter.next(), visitor); } // flag all mappings referenced as base types to be defined as types for (Iterator iter = m_forceTypeMappings.iterator(); iter.hasNext();) { MappingElement mapping = (MappingElement)iter.next(); MappingDetail detail = (MappingDetail)m_mappingMap.get(mapping); detail.setType(true); } }
public boolean visit(IncludeElement node) { try { // force creation of defintions context for containing binding m_context.getFormatDefinitions(); node.prevalidate(m_context); } catch (Throwable t) { m_context.addFatal("Error during validation: " + t.getMessage()); t.printStackTrace(); return false; } return true; } }
ValidationContext vctx = new ValidationContext(loc); FileInputStream is = new FileInputStream(file); BindingElement binding = BindingElement.validateBinding(root.getFileName(), file.toURI().toURL(), is, vctx); if (binding == null || vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) { return null; } else {
binding = BindingElement.readBinding(new FileInputStream(file), path, vctx); binding.setBaseUrl(file.toURI().toURL()); vctx.setBindingRoot(binding); IncludePrevalidationVisitor ipv = new IncludePrevalidationVisitor(vctx); vctx.tourTree(binding, ipv); if (vctx.getErrorCount() != 0 || vctx.getFatalCount() != 0) { ArrayList probs = vctx.getProblems(); System.err.println("Errors in generated binding:"); for (int j = 0; j < probs.size(); j++) {
ArrayList probs = m_context.getProblems(); boolean error = m_context.getErrorCount() > 0 || m_context.getFatalCount() > 0; if (probs.size() > 0) { System.out.print(error ? "Errors" : "Warnings");
/** * Report problems found in binding. * * @param vctx Validation Context * @param handler Problem Handler */ private static void reportBindingProblems(org.jibx.binding.model.ValidationContext vctx, ProblemHandler handler) { StringBuffer buff = new StringBuffer(); ArrayList problems = vctx.getProblems(); for (int i = 0; i < problems.size(); i++) { org.jibx.binding.model.ValidationProblem prob = (org.jibx.binding.model.ValidationProblem)problems.get(i); buff.setLength(0); buff.append(prob.getSeverity() >= org.jibx.binding.model.ValidationProblem.ERROR_LEVEL ? "Error: " : "Warning: "); buff.append(prob.getDescription()); handler.report(buff.toString()); } }
m_context.addWarning("Handling not implemented for unspecified mapping", coll); m_context.addWarning("Handling not implemented for unspecified mapping", struct); m_context.addError("Unsupported binding construct", comp); m_context.addError("Unsupported component", comp);
/** * Constructor. * * @param loc locator for class information (<code>null</code> if none) * @param custom binding customization information (used for creating names as needed) * @param urinames map from namespace URI to schema file name */ public SchemaGen(IClassLocator loc, GlobalCustom custom, Map urinames) { m_locator = loc; m_custom = custom; m_classSimpletypes = new HashMap(); m_uriNames = urinames; m_uriSchemas = new HashMap(); m_formatCache = new FormatterCache(loc); m_context = new ValidationContext(loc); m_detailDirectory = new DetailDirectory(custom, m_context); }
binding = BindingElement.readBinding(new FileInputStream(file), path, vctx); binding.setBaseUrl(file.toURI().toURL()); vctx.setBindingRoot(binding); IncludePrevalidationVisitor ipv = new IncludePrevalidationVisitor(vctx); vctx.tourTree(binding, ipv); if (vctx.getErrorCount() != 0 || vctx.getFatalCount() != 0) { ArrayList probs = vctx.getProblems(); System.err.println("Errors in generated binding:"); for (int j = 0; j < probs.size(); j++) {
FileInputStream is = new FileInputStream(file); try { ValidationContext vctx = new ValidationContext(parms.getLocator()); BindingElement binding = BindingElement.validateBinding(name, url, is, vctx); if (vctx.getErrorCount() == 0 && vctx.getFatalCount() == 0) { bindings.add(binding); } else {
m_context.addError("'extends' mapping not usable as schema extension base", map);
/** * Write the binding definitions file(s). This method can only be used after * {@link #buildDataModel(boolean, boolean, Map, Map)} is called. * * @param name root binding definition file name (use customization, or default, if <code>null</code>) * @param pack target package for binding (<code>null</code> if unspecified) * @param pregens pregenerated bindings to be included in root binding * @param handler validation error and code generation problem handler * @throws JiBXException error * @throws IOException error */ public void writeBindings(String name, String pack, List pregens, ProblemHandler handler) throws JiBXException, IOException { if (name == null) { name = m_global.getBindingFileName(); if (name == null) { name = "binding.xml"; } } m_rootHolder = m_bindingDirectory.configureFiles(name, pack, pregens); IClassLocator iloc = new DummyClassLocator(); org.jibx.binding.model.ValidationContext vctx = new org.jibx.binding.model.ValidationContext(iloc); if (m_bindingDirectory.validateBindings(m_rootHolder, m_targetDir, vctx)) { m_bindingDirectory.writeBindings(m_targetDir); } else { reportBindingProblems(vctx, handler); throw new JiBXException("Terminating due to errors in bindings"); } }
new org.jibx.binding.model.ValidationContext(new DummyClassLocator()); BindingElement binding = BindingElement.readBinding(url.openStream(), name, null, true, vctx); binding.setBaseUrl(url); vctx.setBindingRoot(binding); ArrayList probs = vctx.getProblems(); if (probs.size() > 0) { for (int i = 0; i < probs.size(); i++) { System.out.println(prob.getDescription()); if (vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) { throw new JiBXException("Errors in binding");
public boolean visit(IncludeElement node) { try { // force creation of defintions context for containing binding m_context.getFormatDefinitions(); node.prevalidate(m_context); } catch (Throwable t) { m_context.addFatal("Error during validation: " + t.getMessage()); t.printStackTrace(); return false; } return true; } }