Example usage for org.xml.sax Attributes getValue

List of usage examples for org.xml.sax Attributes getValue

Introduction

In this page you can find the example usage for org.xml.sax Attributes getValue.

Prototype

public abstract String getValue(String qName);

Source Link

Document

Look up an attribute's value by XML qualified (prefixed) name.

Usage

From source file:com.frameworkset.orm.engine.model.Domain.java

/**
 * Imports a column from an XML specification
 *///from  ww  w  .j  a  va 2 s . c  om
public void loadFromXML(Attributes attrib, Platform platform) {
    SchemaType schemaType = SchemaType.getEnum(attrib.getValue("type"));
    copy(platform.getDomainForSchemaType(schemaType));
    //Name
    name = attrib.getValue("name");
    //Default column value.
    defaultValue = attrib.getValue("default");
    size = attrib.getValue("size");
    scale = attrib.getValue("scale");

    description = attrib.getValue("description");
}

From source file:com.quinsoft.zeidon.standardoe.ActivateOisFromXmlStream.java

/**
 * Called to handle the zOI entity./*from  w w w .  j av a  2 s  .  c  o m*/
 *
 * @param qName
 * @param attributes
 */
private void createOi(String qName, Attributes attributes) {
    String appName = attributes.getValue("appName");
    if (StringUtils.isBlank(appName))
        throw new ZeidonException("zOI element does not specify appName");

    application = task.getApplication(appName);
    String odName = attributes.getValue("objectName");
    if (StringUtils.isBlank(odName))
        throw new ZeidonException("zOI element does not specify objectName");

    lodDef = application.getLodDef(task, odName);
    view = (ViewImpl) task.activateEmptyObjectInstance(lodDef);
    viewList.add(view);

    String increFlags = attributes.getValue("increFlags");
    if (!StringUtils.isBlank(increFlags))
        incremental = isYes(increFlags);

    String rootCount = attributes.getValue("totalRootCount");
    if (!StringUtils.isBlank(rootCount))
        view.setTotalRootCount(Integer.parseInt(rootCount));

    // Create a list to keep track of selected instances.
    selectedInstances = new ArrayList<>();
}

From source file:me.crime.loader.DataBaseLoader.java

@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {

    if (name.compareTo(XmlTags.ELEMENT) == 0) {
        current_ = attributes.getValue(XmlTags.NAME);
    } else if (name.compareTo(XmlTags.CLASS) == 0) {
        String className = attributes.getValue(XmlTags.NAME).trim();
        if (this.classMap_.containsKey(className)) {
            className = classMap_.get(className);
        }//  w w  w  . j  a  v  a 2  s.  co  m
        try {
            Class<?> cls = this.getClass().getClassLoader().loadClass(className);
            Object obj = cls.newInstance();
            XmlReadable reader = XmlReadable.class.cast(obj);

            if (curObject_ != null) {
                stack_.push(curObject_);
            }
            curObject_ = reader;

        } catch (InstantiationException e) {
            DataBaseLoader.log_.error("startElement: " + className, e);
        } catch (IllegalAccessException e) {
            DataBaseLoader.log_.error("startElement: " + className, e);
        } catch (ClassNotFoundException e) {
            DataBaseLoader.log_.error("startElement: " + className, e);
        }
    }

}

From source file:SAXCopy.java

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
    System.out.println("<" + qName);
    if (namespaceBegin) {
        System.out.print(" xmlns:" + currentNamespace + "=\"" + currentNamespaceUri + "\"");
        namespaceBegin = false;// w w  w. ja  v a2s. c om
    }
    for (int i = 0; i < atts.getLength(); i++) {
        System.out.print(" " + atts.getQName(i) + "=\\" + atts.getValue(i) + "\"");
    }
    System.out.print(">");
}

From source file:com.ijuru.kumva.xml.EntriesXMLHandler.java

/**
 * @see org.xml.sax.helpers.DefaultHandler#startElement(String, String, String, Attributes)
 *///from   w  w  w . ja v  a2  s .  co  m
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException, NumberFormatException {
    String element = StringUtils.isEmpty(localName) ? qName : localName;

    if (element.equals("entries")) {
        query = attributes.getValue("query");
        suggestion = attributes.getValue("suggestion");
    } else if (element.equals("entry")) {
        curEntry = new Entry();
        curEntry.setEntryId(Integer.parseInt(attributes.getValue("id")));
    } else if (element.equals("revision")) {
        curRevision = new Revision();
        curRevision.setNumber(Integer.parseInt(attributes.getValue("number")));
        curRevision.setStatus(RevisionStatus.parse(attributes.getValue("status")));
        curRevision.setWordClass(attributes.getValue("wordclass"));
        curRevision.setNounClasses(Utils.parseCSVIntegers(attributes.getValue("nounclasses")));
        curRevision.setUnverified(Boolean.parseBoolean(attributes.getValue("unverified")));
    } else if (element.equals("meanings")) {
        inMeanings = true;
    } else if (element.equals("meaning")) {
        int flags = Meaning.parseFlags(attributes.getValue("flags"));
        curMeaning = new Meaning();
        curMeaning.setFlags(flags);
    } else if (element.equals("relationship")) {
        curRelationship = attributes.getValue("name");
        curTags = new ArrayList<Tag>();
    } else if (element.equals("tag")) {
        curTags.add(new Tag(attributes.getValue("lang"), attributes.getValue("text")));
    } else if (element.equals("example")) {
        curExample = new Example();
    }
    /*else if (localName.equals("media")) {
       if ("audio".equals(attributes.getValue("type"))) {
    curDefinition.setAudioURL(attributes.getValue("url"));
       }
    }*/

    elementText = new StringBuilder();
}

From source file:net.sf.joost.instruction.PDocumentFactory.java

public NodeBase createNode(NodeBase parent, String qName, Attributes attrs, ParseContext context)
        throws SAXParseException {
    Tree href = parseRequiredExpr(qName, attrs, "href", context);

    Tree baseAVT = parseAVT(attrs.getValue("base"), context);

    String groupAtt = attrs.getValue("group");

    String filterMethodAtt = attrs.getValue("filter-method");

    if (groupAtt != null && filterMethodAtt != null)
        throw new SAXParseException("It's not allowed to use both 'group' and 'filter-method' " + "attributes",
                context.locator);/*from w  ww  .  ja  va  2s  .co m*/

    String filterSrcAtt = attrs.getValue("filter-src");

    if (filterSrcAtt != null && filterMethodAtt == null)
        throw new SAXParseException(
                "Missing 'filter-method' attribute in '" + qName + "' ('filter-src' is present)",
                context.locator);

    checkAttributes(qName, attrs, attrNames, context);
    return new Instance(qName, parent, context, href, baseAVT, groupAtt, filterMethodAtt, filterSrcAtt);
}

From source file:com.netspective.commons.xml.template.Template.java

public void declareParameter(TemplateContentHandler contentHandler, String url, String localName, String qName,
        Attributes attributes) throws SAXException {
    String paramName = attributes.getValue(NodeIdentifiers.ATTRNAME_TEMPLATE_PARAM_DECL_NAME);
    if (paramName == null || paramName.length() == 0)
        throw new SAXParseException("Template parameter has no '"
                + NodeIdentifiers.ATTRNAME_TEMPLATE_PARAM_DECL_NAME + "' attribute.",
                contentHandler.getDocumentLocator());

    Parameter param = new Parameter(paramName);
    templateParamsDeclarations.put(paramName, param);

    param.setDefaultValue(attributes.getValue(NodeIdentifiers.ATTRNAME_TEMPLATE_PARAM_DECL_DEFAULT));

    String paramRequiredStr = attributes.getValue(NodeIdentifiers.ATTRNAME_TEMPLATE_PARAM_DECL_REQUIRED);
    param.setRequired(paramRequiredStr != null && paramRequiredStr.length() > 0
            ? TextUtils.getInstance().toBoolean(paramRequiredStr)
            : false);/*from   www .  j a v  a 2  s.  c  om*/

    param.setCopyAttribute(attributes.getValue(NodeIdentifiers.ATTRNAME_TEMPLATE_PARAM_DECL_COPYATTR));
}

From source file:at.molindo.webtools.crawler.CrawlerTask.java

protected void parseResult(final String string) throws SAXException, IOException {

    InputSource inputSource;/*  w  w w.  j  a  v  a2 s  .  co m*/
    if (_tidy) {
        final Tidy tidy = new Tidy();
        tidy.setXHTML(true);
        tidy.setErrfile("/dev/null");
        final ByteArrayInputStream in = new ByteArrayInputStream(string.getBytes());
        final ByteArrayOutputStream out = new ByteArrayOutputStream();

        tidy.parse(in, out);

        inputSource = new InputSource(new ByteArrayInputStream(out.toByteArray()));
    } else {
        inputSource = new InputSource(new StringReader(string));
    }

    ((CrawlerThread) Thread.currentThread()).getParser().parse(inputSource, new DefaultHandler() {

        @Override
        public void startElement(final String uri, final String localName, final String name,
                final Attributes attributes) throws SAXException {

            if ("a".equals(name)) {
                String href = attributes.getValue("href");
                if (href != null) {
                    final int anchorIndex = href.lastIndexOf("#");
                    if (anchorIndex > 0) {
                        href = href.substring(0, anchorIndex);
                    } else if (anchorIndex == 0) {
                        // anchor on same page: ignore
                        return;
                    }

                    if (href != null) {
                        final CrawlerReferrer referrer = new CrawlerReferrer(_urlString, href);
                        if (!href.startsWith("http://")) {
                            if (href.startsWith("/")) {
                                _crawler.queue(_crawler._host + href.substring(1), referrer);
                            } else if (!href.startsWith("javascript:") && !href.startsWith("ftp:")
                                    && !href.startsWith("mailto:")) {
                                String relativeTo = _urlString.substring(0, _urlString.lastIndexOf("/"));
                                boolean one = false, two = false;
                                while ((two = href.startsWith("../")) || (one = href.startsWith("./"))) {
                                    if (two) {
                                        href = href.substring(3);
                                        relativeTo = relativeTo.substring(0, relativeTo.lastIndexOf("/"));
                                    } else if (one) {
                                        href = href.substring(2);
                                    }
                                }

                                _crawler.queue(relativeTo + "/" + href, referrer);
                            }
                        } else if (href.startsWith(_crawler._host)) {
                            _crawler.queue(href, referrer);
                        }
                    }
                }
            }
        }

        @Override
        public InputSource resolveEntity(final String publicId, String systemId)
                throws IOException, SAXException {
            if ("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd".equals(systemId)) {
                systemId = getClass().getClassLoader().getResource("xhtml1-transitional.dtd").toString();
            }

            return _crawler.getDtdMemoryCache().resolveEntity(publicId, systemId);
        }
    });
}

From source file:SAXCopy.java

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
    out.print("<" + qName);
    if (namespaceBegin) {
        out.print(" xmlns:" + currentNamespace + "=\"" + currentNamespaceUri + "\"");
        namespaceBegin = false;//from  www .j  a va 2s . co  m
    }
    for (int i = 0; i < atts.getLength(); i++) {
        out.print(" " + atts.getQName(i) + "=\\" + atts.getValue(i) + "\"");
    }
    out.print(">");
}

From source file:bbcdataservice.BBCProgrammesParser.java

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    try {/*  w  ww  . ja  va 2 s .com*/
        mText.setLength(0);
        if ("programme".equalsIgnoreCase(qName)) {
            String programType = attributes.getValue("type");
            if ("episode".equalsIgnoreCase(programType)) {
                mProgramType = PROGRAMME_TYPE_EPISODE;
            } else if ("series".equalsIgnoreCase(programType)) {
                mProgramType = PROGRAMME_TYPE_SERIES;
            } else if ("brand".equalsIgnoreCase(programType)) {
                mProgramType = PROGRAMME_TYPE_BRAND;
            }
        } else if ("ownership".equalsIgnoreCase(qName) || "display_titles".equalsIgnoreCase(qName)) {
            mIgnoreElements = true;
        } else if ("day".equalsIgnoreCase(qName)) {
            mHasNextDay = attributes.getValue("has_next").equals("1");
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}