Package com.ctc.wstx.ent

Examples of com.ctc.wstx.ent.EntityDecl


        assertEquals("root", sr.getLocalName());

        assertTokenType(CHARACTERS, sr.next());
        assertTokenType(ENTITY_REFERENCE, sr.next());
        assertEquals("myent", sr.getLocalName());
        EntityDecl ed = sr.getCurrentEntityDecl();
        assertNotNull(ed);
        assertEquals("myent", ed.getName());
        assertEquals("value", ed.getReplacementText());

        // The pure stax way:
        assertEquals("value", sr.getText());

        // Finally, let's see that location info is about right?
        Location loc = ed.getLocation();
        assertNotNull(loc);
        assertEquals(2, loc.getLineNumber());

        /* Hmmh. Not 100% if this location makes sense, but... it's the
         * current behaviour, so we can regression test it.
View Full Code Here


        } catch (XMLStreamException sex) {
            fail("Did not except a stream exception on undeclared entity in non-entity-expanding mode; got: "+sex);
        }

        assertEquals("myent", sr.getLocalName());
        EntityDecl ed = sr.getCurrentEntityDecl();
        assertNull(ed);

        assertTokenType(CHARACTERS, sr.next());
        assertTokenType(END_ELEMENT, sr.next());
        assertEquals("root", sr.getLocalName());
View Full Code Here

        for (Map.Entry<?,?> entry : mr.entrySet()) {
            String name = entry.getKey().toString();
            if (name.equals("myent") || name.equals("myent2")
                || name.equals("myent3")) {
                // fine, let's just verify the type
                EntityDecl ed = (EntityDecl) entry.getValue();
                assertNotNull(ed);
            } else {
                fail("Unexpected entity '"+name+"' in the custom entity map");
            }
        }
View Full Code Here

            {
                /* 19-Jul-2006, TSa: Let's also allow other impls, although
                 *   we can't get actual declaration if so...
                 */
                if (r instanceof StreamReaderImpl) {
                    EntityDecl ed = ((StreamReaderImpl) r).getCurrentEntityDecl();
                    if (ed == null) { // undefined?
                    // We'll still know the name though...
                        return new WEntityReference(loc, r.getLocalName());
                    }
                    return new WEntityReference(loc, ed);
View Full Code Here

                    return reportInvalidChar(v, c, "not valid as an ENTITIES character");
                }
                hash = (hash * 31) + (int) c;
            }

            EntityDecl ent = findEntityDecl(v, cbuf, start, (i - start), hash);
            // only returns if entity was found...
           
            // Can skip the trailing space char (if there was one)
            start = i+1;

            /* When normalizing, we can possibly share id String, or
             * alternatively, compose normalized String if multiple
             */
            if (normalize) {
                if (idStr == null) { // first idref
                    idStr = ent.getName();
                } else {
                    if (sb == null) {
                        sb = new StringBuffer(idStr);
                    }
                    idStr = ent.getName();
                    sb.append(' ');
                    sb.append(idStr);
                }
            }

View Full Code Here

         *   to expose a special method... but it gets things done.
         */
        MinimalDTDReader dtdr = (MinimalDTDReader) rep;
        while (st.hasMoreTokens()) {
            String str = st.nextToken();
            EntityDecl ent = dtdr.findEntity(str);
            // Needs to exists, and be an unparsed entity...
            checkEntity(rep, normStr, ent);
        }
    }
View Full Code Here

                return reportInvalidChar(v, c, "not valid as an ID character");
            }
            hash = (hash * 31) + (int) c;
        }

        EntityDecl ent = findEntityDecl(v, cbuf, start, (end - start + 1), hash);
        // only returns if it succeeded...

        return normalize ? ent.getName() : null;
    }
View Full Code Here

        /* 03-Dec-2004, TSa: This is rather ugly -- need to know we
         *   actually really get a DTD reader, and DTD reader needs
         *   to expose a special method... but it gets things done.
         */
        EntityDecl ent = ((MinimalDTDReader) rep).findEntity(normStr);
        checkEntity(rep, normStr, ent);
    }
View Full Code Here

            /* Nope; was a general entity... in auto-mode, it's now been
             * expanded; in non-auto, need to figure out entity itself.
             */
            if (!mCfgReplaceEntities) {
                EntityDecl ed = resolveNonCharEntity();
                // Note: ed may still be null at this point
                mTokenState = TOKEN_FULL_COALESCED;
                mCurrEntity = ed;
                /*
                // let's not worry about non-parsed entities, since this is unexpanded mode
View Full Code Here

    // @Override
    protected EntityDecl findEntity(String id, Object arg)
        throws XMLStreamException
    {
        EntityDecl ed = null;

        if (mCustomEntities != null) {
            ed = (EntityDecl) mCustomEntities.get(id);
        }
        if (ed == null && mGeneralEntities != null) {
            ed = (EntityDecl) mGeneralEntities.get(id);
        }
        /* 05-Mar-2006, TSa: Externally declared entities are illegal
         *   if we were declared as "standalone='yes'"...
         */
        if (mDocStandalone == DOC_STANDALONE_YES) {
            if (ed != null && ed.wasDeclaredExternally()) {
                throwParseError(ErrorConsts.ERR_WF_ENTITY_EXT_DECLARED, ed.getName());
            }
        }

        return ed;
    }
View Full Code Here

TOP

Related Classes of com.ctc.wstx.ent.EntityDecl

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.