Package org.jibx.schema.elements

Examples of org.jibx.schema.elements.AnnotatedBase


                   
                } else if (item instanceof ReferenceItem) {
                   
                    // make sure namespace collected for reference
                    DefinitionItem def = ((ReferenceItem)item).getDefinition();
                    AnnotatedBase defcomp = def.getSchemaComponent();
                    if (defcomp instanceof INamed) {
                        QName qname = ((INamed)defcomp).getQName();
                        if (qname == null && defcomp instanceof IReference) {
                            qname = ((IReference)defcomp).getRef();
                        }
View Full Code Here


        } else {
           
            // scan the item tree structure to find schema components needing special handling
            Map comptoclas = new HashMap();
            InsertionOrderedSet refcomps = new InsertionOrderedSet();
            AnnotatedBase grpcomp = group.getSchemaComponent();
            refcomps.add(grpcomp);
            Map uritoprefix = new HashMap();
            if (grpcomp instanceof INamed) {
                QName qname = ((INamed)grpcomp).getQName();
                if (qname == null && grpcomp instanceof IReference) {
                    qname = ((IReference)grpcomp).getRef();
                }
                if (qname != null && qname.getUri() != null) {
                    uritoprefix.put(qname.getUri(), qname.getPrefix());
                }
            }
            scanItemTree(group, comptoclas, refcomps, uritoprefix);
           
            // get full set of namespaces and corresponding prefixes needed for extracts
            UniqueNameSet prefset = new UniqueNameSet();
            prefset.add(m_schemaPrefix);
            for (Iterator iter = uritoprefix.keySet().iterator(); iter.hasNext();) {
                String uri = (String)iter.next();
                if (!SCHEMA_DEFINITIONS_NS.equals(uri)) {
                    String prefix = (String)uritoprefix.get(uri);
                    if (prefix == null) {
                        prefix = "ns";
                    }
                    prefix = prefset.add(prefix);
                    uritoprefix.put(uri, prefix);
                }
               
            }
           
            // set the writer to be used for output
            StringWriter strwriter = new StringWriter();
            m_context.setOutput(strwriter);
           
            // define namespaces as extension to those used in binding
            int count = uritoprefix.size();
            String[] uris = (String[])uritoprefix.keySet().toArray(new String[count]);
            IXMLWriter xmlwriter = m_context.getXmlWriter();
            int base = xmlwriter.getNamespaceCount();
            xmlwriter.pushExtensionNamespaces(uris);
           
            // build the arrays of namespace indexes and prefixes for use on marshalled root elements
            int length = count;
            if (!uritoprefix.containsKey(null)) {
                length++;
            }
            String[] prefixes = new String[length];
            int[] indexes = new int[length];
            int fill = 0;
            for (int i = 0; i < count; i++) {
                String uri = uris[i];
                if (uri != null) {
                    prefixes[fill] = (String)uritoprefix.get(uris[i]);
                    indexes[fill] = base+fill;
                    fill++;
                }
            }
            prefixes[fill] = m_schemaPrefix;
            indexes[fill] = m_schemaIndex;
           
            // build schema extracts from main component and all referenced components
            String clasname = group.getGenerateClass().getFullName();
            TreeWalker walker = new TreeWalker(null, new SchemaContextTracker());
            boolean ref = false;
            List list = refcomps.asList();
            for (Iterator iter = list.iterator(); iter.hasNext();) {
               
                // add a blank line separating components
                if (ref) {
                    strwriter.write(COMMENT_LEAD_TEXT);
                } else {
                    ref = true;
                }
               
                // add any necessary namespace declarations
                AnnotatedBase comp = (AnnotatedBase)iter.next();
                for (Iterator jter = uritoprefix.keySet().iterator(); jter.hasNext();) {
                    String uri = (String)jter.next();
                    comp.addNamespaceDeclaration((String)uritoprefix.get(uri), uri);
                }
               
                // write the documentation
                DocumentationVisitor visitor = new DocumentationVisitor(comptoclas, clasname, comp, dropanno, ref,
                    indexes, prefixes);
View Full Code Here

TOP

Related Classes of org.jibx.schema.elements.AnnotatedBase

Copyright © 2018 www.massapicom. 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.