Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.AttributesImpl


        throws Exception
    {
        final SAXConfigurationHandler handler = new SAXConfigurationHandler();
        final String qName = "myElement";
        final String value = "   \n   \t";
        handler.startElement( "", "", qName, new AttributesImpl() );
        handler.characters( value.toCharArray(), 0, value.length() );
        handler.endElement( "", "", qName );
        final Configuration configuration = handler.getConfiguration();
        assertEquals( "configuration.name", qName, configuration.getName() );
        assertEquals( "configuration.location", "", configuration.getLocation() );
View Full Code Here


    public void testCreateConfigurationWithAttributes()
        throws Exception
    {
        final SAXConfigurationHandler handler = new SAXConfigurationHandler();
        final String qName = "myElement";
        final AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute( "", "", "key", "CDATA", "value" );
        handler.startElement( "", "", qName, attributes );
        handler.endElement( "", "", qName );
        final Configuration configuration = handler.getConfiguration();
        assertEquals( "configuration.name", qName, configuration.getName() );
        assertEquals( "configuration.location", "", configuration.getLocation() );
View Full Code Here

    public void testCreateConfigurationWithAttributesWithInterception()
        throws Exception
    {
        final SAXConfigurationHandler handler = new MockSAXConfigurationHandler();
        final String qName = "myElement";
        final AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute( "", "", "key", "CDATA", "value" );
        handler.startElement( "", "", qName, attributes );
        handler.endElement( "", "", qName );
        final Configuration configuration = handler.getConfiguration();
        assertEquals( "configuration.name", qName, configuration.getName() );
        assertEquals( "configuration.location", "", configuration.getLocation() );
View Full Code Here

    public void testSerializeZeroLengthAttributes()
        throws Exception
    {
        final DefaultConfiguration configuration = new DefaultConfiguration( "element", "", "" );
        final SAXConfigurationSerializer serializer = new SAXConfigurationSerializer();
        final AttributesImpl attributes = serializer.serializeAttributes( configuration );
        assertEquals( "attributes.getLength()", 0, attributes.getLength() );
    }
View Full Code Here

        final DefaultConfiguration configuration = new DefaultConfiguration( "element", "", "" );
        final String name = "key";
        final String value = "value";
        configuration.setAttribute( name, value );
        final SAXConfigurationSerializer serializer = new SAXConfigurationSerializer();
        final AttributesImpl attributes = serializer.serializeAttributes( configuration );
        assertEquals( "attributes.getLength()", 1, attributes.getLength() );
        assertEquals( "attributes.getLocalName(0)", name, attributes.getLocalName( 0 ) );
        assertEquals( "attributes.getQName(0)", name, attributes.getQName( 0 ) );
        assertEquals( "attributes.getURI(0)", "", attributes.getURI( 0 ) );
        assertEquals( "attributes.getType(0)", "CDATA", attributes.getType( 0 ) );
        assertEquals( "attributes.getType(0)", value, attributes.getValue( 0 ) );
    }
View Full Code Here

     */
    void serializeElement( final Configuration configuration,
                           final ContentHandler handler )
        throws SAXException
    {
        final AttributesImpl attributes = serializeAttributes( configuration );

        final String name = configuration.getName();
        handler.startElement( EMPTY_NAMESPACE, name, name, attributes );

        String value = configuration.getValue( null );
View Full Code Here

     * @param configuration the configuration
     * @return the AttributesImpl instance
     */
    AttributesImpl serializeAttributes( final Configuration configuration )
    {
        final AttributesImpl attributes = new AttributesImpl();
        final String[] names = configuration.getAttributeNames();
        for( int i = 0; i < names.length; i++ )
        {
            final String name = names[ i ];
            final String value = configuration.getAttribute( name, "" );
            attributes.addAttribute( EMPTY_NAMESPACE, name, name,
                                     CDATA_TYPE, value );
        }
        return attributes;
    }
View Full Code Here

    protected void startTokenHighlight(XMLOutput output, String cssClass) throws SAXException
    {
        if (cssClass != null)
        {
            AttributesImpl attributes = new AttributesImpl();
            attributes.addAttribute("", "class", "class", "string", cssClass);
            output.startElement("div", attributes);
        }
    }
View Full Code Here

  }

  protected void write(Element element, NamespaceStack namespaceStack)
      throws SAXException {
    int stackSize = namespaceStack.size();
    AttributesImpl namespaceAttributes = startPrefixMapping(element,
        namespaceStack);
    startElement(element, namespaceAttributes);
    writeContent(element, namespaceStack);
    endElement(element);
    endPrefixMapping(namespaceStack, stackSize);
View Full Code Here

   * @return DOCUMENT ME!
   * @throws SAXException DOCUMENT ME!
   */
  protected AttributesImpl startPrefixMapping(Element element,
                                              NamespaceStack namespaceStack) throws SAXException {
    AttributesImpl namespaceAttributes = null;

    // start with the namespace of the element
    Namespace elementNamespace = element.getNamespace();

    if ((elementNamespace != null)
View Full Code Here

TOP

Related Classes of org.xml.sax.helpers.AttributesImpl

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.