Examples of SchemaElement


Examples of org.jibx.schema.elements.SchemaElement

     * @param text schema text
     * @param msg text for wrong number of errors found
     * @throws Exception on unexpected error
     */
    protected void runOneError(String text, String msg) throws Exception {
        SchemaElement schema = readSchema(text, m_validationContext);
        validateSchema(schema, m_validationContext);
        assertTrue(msg, hasProblem(m_validationContext));
    }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     * @return schema
     * @throws Exception on unexpected error
     */
    protected SchemaElement prepareSchema(String text) throws Exception {
        m_validationContext.reset();
        SchemaElement schema = readSchema(text, m_validationContext);
        validateSchema(schema, m_validationContext);
        assertFalse(getProblemText(m_validationContext), hasProblem(m_validationContext));
        return schema;
    }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     * @param text schema text
     * @return schema
     * @throws Exception on unexpected error
     */
    protected SchemaElement runNoErrors(String text) throws Exception {
        SchemaElement schema = prepareSchema(text);
        verifySchema(text, writeSchema(schema));
        return schema;
    }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     * @param resolve resolver for all schema texts
     * @return root schema
     * @throws Exception
     */
    protected SchemaElement loadSchema(TestResolver resolve) throws Exception {
        SchemaElement schema = readSchema(resolve.getContent(), m_validationContext);
        schema.setResolver(resolve);
        m_validationContext.setSchema(resolve.getName(), schema);
        validateSchema(schema, m_validationContext);
        assertFalse(getProblemText(m_validationContext), hasProblem(m_validationContext));
        verifySchema(resolve.getText(), writeSchema(schema));
        return schema;
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

                    // check for no-namespace schema imported into namespace
                    int depth = ictx.getStackDepth();
                    for (int i = 0; i < depth; i++) {
                        Object obj = ictx.getStackObject(i);
                        if (obj instanceof SchemaElement) {
                            SchemaElement schema = (SchemaElement)obj;
                            String ens = schema.getEffectiveNamespace();
                            if (ens != schema.getTargetNamespace()) {
                                return qname.getName();
                            } else {
                                break;
                            }
                        }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

        // set up validation with in-memory schemas
        org.jibx.schema.validation.ValidationContext vctx = new org.jibx.schema.validation.ValidationContext();
        for (int i = 0; i < holders.size(); i++) {
            SchemaHolder holder = (SchemaHolder)holders.get(i);
            String id = holder.getFileName();
            SchemaElement schema = holder.getSchema();
            schema.setResolver(new MemoryResolver(id));
            vctx.setSchema(id, schema);
        }
        for (Iterator iter = exists.iterator(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            vctx.setSchema(schema.getResolver().getName(), schema);
        }
       
        // validate the schemas and report any problems
        ValidationUtils.validateSchemas(schemas, vctx);
        ArrayList probs = vctx.getProblems();
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     */
    public void prevalidate(ValidationContext vctx) {
        if (m_ref != null && m_name != null) {
            vctx.addError("Cannot use both 'ref' and 'name'", getOwner());
        }
        SchemaElement schema = vctx.getCurrentSchema();
        String ens = schema.getEffectiveNamespace();
        QNameConverter.patchQNameNamespace(ens, m_ref);
    }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     *
     * @param iter schema iterator
     */
    public void setDefaultPrefixes(Iterator iter) {
        while (iter.hasNext()) {
            SchemaElement schema = (SchemaElement)iter.next();
            ArrayList decls = schema.getNamespaceDeclarations();
            for (int i = 0; i < decls.size(); i++) {
                String prefix = (String)decls.get(i++);
                m_bindingDirectory.addDefaultPrefix((String)decls.get(i), prefix);
            }
        }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

        m_packageDirectory = new PackageOrganizer(m_targetDir, dfltpack);
       
        // link each schema to a customization, creating a default customization if necessary
        int count = 0;
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            ISchemaResolver resolver = schema.getResolver();
            s_logger.debug("Assigning customization for schema " + ++count + ": " + resolver.getName());
            SchemasetCustom owner = findSchemaset(schema, m_global);
            SchemaCustom custom = owner.forceCustomization(resolver.getName(), resolver.getId(), schema,
                m_validationContext);
            custom.validate(m_validationContext);
            String pname = custom.getPackage();
            PackageHolder holder = null;
            if (pname == null) {
                String uri = schema.getEffectiveNamespace();
                if (uri == null) {
                    uri = "";
                }
                holder = m_packageDirectory.getPackageForUri(uri);
            } else {
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     */
    private boolean processExtensions() {
       
        // first clear all the cross reference information
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            int count = schema.getChildCount();
            for (int i = 0; i < count; i++) {
                SchemaBase child = schema.getChild(i);
                Object obj = child.getExtension();
                if (obj instanceof GlobalExtension) {
                    ((GlobalExtension)obj).resetDependencies();
                }
            }
        }
       
        // process each loaded schema for deletions and cross referencing
        int index = 0;
        m_validationContext.clearTraversed();
        boolean modified = false;
        // Level level = TreeWalker.setLogging(s_logger.getLevel());
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            m_validationContext.enterSchema(schema);
            s_logger.debug("Applying extensions to schema " + ++index + ": " + schema.getResolver().getName());
            int count = schema.getChildCount();
            boolean instmod = false;
            for (int i = 0; i < count; i++) {
                SchemaBase child = schema.getChild(i);
                Object obj = child.getExtension();
                if (obj instanceof GlobalExtension) {
                   
                    // apply extension to global definition element
                    ComponentExtension exten = (ComponentExtension)obj;
                    if (exten.isRemoved()) {
                       
                        // just eliminate this definition from the schema
                        schema.detachChild(i);
                        instmod = true;
                       
                    } else {
                       
                        // process the definition to remove references to deleted components
                        exten.applyAndCountUsage(m_validationContext);
                       
                    }
                }
            }
            if (instmod) {
                schema.compactChildren();
                modified = true;
            }
            m_validationContext.exitSchema();
           
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.