Package org.fcrepo.utilities

Examples of org.fcrepo.utilities.NamespaceContextImpl


        Document doc = builder.parse(input);

        // set up the xpath stuff
        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPath xpath = xpathFactory.newXPath();
        NamespaceContextImpl nsCtx = new NamespaceContextImpl();
        nsCtx.addNamespace("foxml", Constants.FOXML.uri);
        nsCtx.addNamespace("oai_dc", Constants.OAI_DC.uri);
        nsCtx.addNamespace("dc", Constants.DC.uri);
        nsCtx.addNamespace("rdf", Constants.RDF.uri);
        xpath.setNamespaceContext(nsCtx);

        TransformerFactory transfac = TransformerFactory.newInstance();

View Full Code Here


    /**
     * Test method for {@link org.fcrepo.utilities.NamespaceContextImpl#NamespaceContextImpl()}.
     */
    @Test
    public void testNamespaceContextImpl() {
        NamespaceContextImpl nsCtx = new NamespaceContextImpl();
        assertEquals(XMLNamespace.NULL_NS_URI, nsCtx.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX));
        assertEquals(XMLConstants.XML_NS_URI, nsCtx.getNamespaceURI(XMLConstants.XML_NS_PREFIX));
        assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, nsCtx.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE));
    }
View Full Code Here

    public void testNamespaceContextImplMapOfStringString() {
        //NamespaceContextImpl nsCtx;
        Map<String, String> map = new HashMap<String, String>();
        map.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
        try {
            new NamespaceContextImpl(map);
            fail("Added a mapping for " + XMLConstants.XML_NS_URI);
        } catch(IllegalArgumentException e) {
            assertTrue(e.getMessage().endsWith("not allowed."));
        }
View Full Code Here

    /**
     * Test method for {@link org.fcrepo.utilities.NamespaceContextImpl#getNamespaceURI(java.lang.String)}.
     */
    @Test
    public void testGetNamespaceURI() {
        NamespaceContextImpl nsCtx = new NamespaceContextImpl();
        assertEquals(XMLNamespace.NULL_NS_URI, nsCtx.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX));
        assertEquals(XMLConstants.XML_NS_URI, nsCtx.getNamespaceURI(XMLConstants.XML_NS_PREFIX));
        assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, nsCtx.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE));
    }
View Full Code Here

    /**
     * Test method for {@link org.fcrepo.utilities.NamespaceContextImpl#getPrefix(java.lang.String)}.
     */
    @Test
    public void testGetPrefix() {
        NamespaceContextImpl nsCtx = new NamespaceContextImpl();

        assertEquals(XMLConstants.XML_NS_PREFIX, nsCtx.getPrefix(XMLConstants.XML_NS_URI));
        assertEquals(XMLConstants.XMLNS_ATTRIBUTE, nsCtx.getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI));
    }
View Full Code Here

    /**
     * Test method for {@link org.fcrepo.utilities.NamespaceContextImpl#getPrefixes(java.lang.String)}.
     */
    @Test
    public void testGetPrefixes() {
        NamespaceContextImpl nsCtx = new NamespaceContextImpl();
        String prefix = "foo";
        String ns = "http://www.example.org/foo";
        nsCtx.addNamespace(prefix, ns);

        Iterator<String> it = nsCtx.getPrefixes(ns);
        assertNotNull(it);
        assertTrue(it.hasNext());
        assertEquals(prefix, it.next());
        try {
            it.remove();
            fail("remove() succeeded on what should be an unmodifiable Iterator.");
        } catch(UnsupportedOperationException e) {}
        assertFalse(it.hasNext());

        it = nsCtx.getPrefixes("noMapping");
        assertNotNull(it);
        assertFalse(it.hasNext());
    }
View Full Code Here

    /**
     * Test method for {@link org.fcrepo.utilities.NamespaceContextImpl#addNamespace(java.lang.String, java.lang.String)}.
     */
    @Test
    public void testAddNamespace() {
        NamespaceContextImpl nsCtx = new NamespaceContextImpl();
        String prefix = "foo";
        String ns = "http://www.example.org/foo";
        nsCtx.addNamespace(prefix, ns);
        assertEquals(ns, nsCtx.getNamespaceURI(prefix));
        assertEquals(prefix, nsCtx.getPrefix(ns));
    }
View Full Code Here

TOP

Related Classes of org.fcrepo.utilities.NamespaceContextImpl

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.