Java Code Examples for org.xml.sax.Attributes
The following examples show how to use
org.xml.sax.Attributes.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: TVRemoteIME Author: kingthy File: DIDLParser.java License: GNU General Public License v2.0 | 6 votes |
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); if (!DIDLContent.NAMESPACE_URI.equals(uri)) return; if (localName.equals("container")) { Container container = createContainer(attributes); getInstance().addContainer(container); createContainerHandler(container, this); } else if (localName.equals("item")) { Item item = createItem(attributes); getInstance().addItem(item); createItemHandler(item, this); } else if (localName.equals("desc")) { DescMeta desc = createDescMeta(attributes); getInstance().addDescMetadata(desc); createDescMetaHandler(desc, this); } }
Example #2
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: PayloadElementSniffer.java License: GNU General Public License v2.0 | 6 votes |
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (bodyStarted) { payloadQName = new QName(uri, localName); // we have what we wanted - let's skip rest of parsing ... throw new SAXException("Payload element found, interrupting the parsing process."); } // check for both SOAP 1.1/1.2 if (equalsQName(uri, localName, SOAPConstants.QNAME_SOAP_BODY) || equalsQName(uri, localName, SOAP12Constants.QNAME_SOAP_BODY)) { bodyStarted = true; } }
Example #3
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: DOMBuilder.java License: GNU General Public License v2.0 | 6 votes |
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) { super.startElement(namespaceURI, localName, qName, atts); Element e = getCurrentElement(); locatorTable.storeStartLocation( e, locator ); // check if this element is an outer-most <jaxb:bindings> if( JAXWSBindingsConstants.JAXWS_BINDINGS.getNamespaceURI().equals(e.getNamespaceURI()) && "bindings".equals(e.getLocalName()) ) { // if this is the root node (meaning that this file is an // external binding file) or if the parent is XML Schema element // (meaning that this is an "inlined" external binding) Node p = e.getParentNode(); if( p instanceof Document) { outerMostBindings.add(e); // remember this value } } }
Example #4
Source Project: jasperreports Author: TIBCOSoftware File: JRChartPlotFactory.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public Object createObject(Attributes atts) { int seriesIndex = -1; Color color = null; String seriesNumber = atts.getValue(JRXmlConstants.ATTRIBUTE_seriesOrder); if (seriesNumber != null && seriesNumber.length() > 0) { seriesIndex = Integer.valueOf(seriesNumber); } String colorName = atts.getValue(JRXmlConstants.ATTRIBUTE_color); if (colorName != null && colorName.length() > 0) { color = JRColorUtil.getColor(colorName, null); } return new JRBaseChartPlot.JRBaseSeriesColor(seriesIndex, color); }
Example #5
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: ersSet.java License: GNU General Public License v2.0 | 6 votes |
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException { int $ai; $uri = $__uri; $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { case 0: { revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs); } break; default: { unexpectedEnterElement($__qname); } break; } }
Example #6
Source Project: microMathematics Author: mkulesh File: SVGParser.java License: GNU General Public License v3.0 | 6 votes |
private void marker(Attributes attributes) throws SVGParseException { debug("<marker>"); if (currentElement == null) throw new SVGParseException("Invalid document. Root element must be <svg>"); SVG.Marker obj = new SVG.Marker(); obj.document = svgDocument; obj.parent = currentElement; parseAttributesCore(obj, attributes); parseAttributesStyle(obj, attributes); parseAttributesConditional(obj, attributes); parseAttributesViewBox(obj, attributes); parseAttributesMarker(obj, attributes); currentElement.addChild(obj); currentElement = obj; }
Example #7
Source Project: netbeans Author: apache File: ResourceRegistrationHelper.java License: Apache License 2.0 | 6 votes |
@Override public void readAttributes(String qname, Attributes attributes) throws SAXException { properties = new HashMap<String, String>(); String resourceName = attributes.getValue(nameKey); properties.put(nameKey, resourceName); //NOI18N int attrLen = attributes.getLength(); for (int i = 0; i < attrLen; i++) { String name = attributes.getLocalName(i); String value = attributes.getValue(i); if (name != null && name.length() > 0 && value != null && value.length() > 0) { properties.put(name, value); } } }
Example #8
Source Project: jdk1.8-source-analysis Author: raysonfang File: SynthParser.java License: Apache License 2.0 | 6 votes |
private void startStyle(Attributes attributes) throws SAXException { String id = null; _style = null; for(int i = attributes.getLength() - 1; i >= 0; i--) { String key = attributes.getQName(i); if (key.equals(ATTRIBUTE_CLONE)) { _style = (ParsedSynthStyle)((ParsedSynthStyle)lookup( attributes.getValue(i), ParsedSynthStyle.class)). clone(); } else if (key.equals(ATTRIBUTE_ID)) { id = attributes.getValue(i); } } if (_style == null) { _style = new ParsedSynthStyle(); } register(id, _style); }
Example #9
Source Project: jdk8u60 Author: chenghanpeng File: foreignAttributes.java License: GNU General Public License v2.0 | 6 votes |
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException { int $ai; $uri = $__uri; $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { case 0: { revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs); } break; default: { unexpectedEnterElement($__qname); } break; } }
Example #10
Source Project: jdk1.8-source-analysis Author: raysonfang File: MutableAttrListImpl.java License: Apache License 2.0 | 6 votes |
/** * Add the contents of the attribute list to this list. * * @param atts List of attributes to add to this list */ public void addAttributes(Attributes atts) { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; String localName = atts.getLocalName(i); String qname = atts.getQName(i); int index = this.getIndex(uri, localName); // System.out.println("MutableAttrListImpl#addAttributes: "+uri+":"+localName+", "+index+", "+atts.getQName(i)+", "+this); if (index >= 0) this.setAttribute(index, uri, localName, qname, atts.getType(i), atts.getValue(i)); else addAttribute(uri, localName, qname, atts.getType(i), atts.getValue(i)); } }
Example #11
Source Project: jasperreports Author: TIBCOSoftware File: SortComponentSymbolFontFactory.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public void setStyle(JRFont font, Attributes atts) { JRDesignFont designFont = (JRDesignFont)font; String styleName = atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont); if (styleName != null) { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); Map<String,JRStyle> stylesMap = jasperDesign.getStylesMap(); if (stylesMap.containsKey(styleName)) { JRStyle style = stylesMap.get(styleName); designFont.setStyle(style); } else { designFont.setStyleNameReference(styleName); } } }
Example #12
Source Project: netbeans Author: apache File: FxModelBuilder.java License: Apache License 2.0 | 6 votes |
@NbBundle.Messages({ "#0 - attribute name", "ERR_unexpectedScriptAttribute=Unexpected attribute in fx:script: {0}" }) private FxNode handleFxScript(Attributes atts) { String ref = null; for (int i = 0; i < atts.getLength(); i++) { String name = atts.getLocalName(i); if (!FX_ATTR_REFERENCE_SOURCE.equals(name)) { addAttributeError(atts.getQName(i), "invalid-script-attribute", ERR_unexpectedScriptAttribute(name), name ); continue; } ref = atts.getValue(i); } return accessor.createScript(ref); }
Example #13
Source Project: Tomcat8-Source-Read Author: chenmudu File: Validator.java License: MIT License | 6 votes |
private String findUri(String prefix, Node n) { for (Node p = n; p != null; p = p.getParent()) { Attributes attrs = p.getTaglibAttributes(); if (attrs == null) { continue; } for (int i = 0; i < attrs.getLength(); i++) { String name = attrs.getQName(i); int k = name.indexOf(':'); if (prefix == null && k < 0) { // prefix not specified and a default ns found return attrs.getValue(i); } if (prefix != null && k >= 0 && prefix.equals(name.substring(k + 1))) { return attrs.getValue(i); } } } return null; }
Example #14
Source Project: entity-fishing Author: kermitt2 File: XmlUtils.java License: Apache License 2.0 | 6 votes |
/** * Build a start tag. * * @param pTagName * name of the tag. * * @param pAtts * the attributes of the tag * @return requested tag. */ public static String startTag(String pTagName, Attributes pAtts) { StringBuilder tag = new StringBuilder(); tag.append(TAG_START_LOW); tag.append(pTagName); String name; String value; for (int i = 0; i < pAtts.getLength(); i++) { name = pAtts.getQName(i); value = pAtts.getValue(i); tag.append(SPACE); tag.append(name); tag.append(EQUALS); tag.append(QUOTE); tag.append(value); tag.append(QUOTE); } tag.append(TAG_START_SUP); return tag.toString(); }
Example #15
Source Project: JDKSourceCode1.8 Author: wupeixuan File: SynthParser.java License: MIT License | 6 votes |
private void startImageIcon(Attributes attributes) throws SAXException { String path = null; String id = null; for(int i = attributes.getLength() - 1; i >= 0; i--) { String key = attributes.getQName(i); if (key.equals(ATTRIBUTE_ID)) { id = attributes.getValue(i); } else if (key.equals(ATTRIBUTE_PATH)) { path = attributes.getValue(i); } } if (path == null) { throw new SAXException("imageIcon: you must specify a path"); } register(id, new LazyImageIcon(getResource(path))); }
Example #16
Source Project: kogito-runtimes Author: kiegroup File: ExtensibleXmlParser.java License: Apache License 2.0 | 6 votes |
/** * Start a configuration node. * * @param tagName * Tag name. * @param attrs * Tag attributes. */ public void startElementBuilder(final String tagName, final Attributes attrs) { this.attrs = attrs; this.characters = new StringBuilder(); final Element element = this.document.createElement( tagName ); //final DefaultConfiguration config = new DefaultConfiguration( tagName ); final int numAttrs = attrs.getLength(); for ( int i = 0; i < numAttrs; ++i ) { element.setAttribute( attrs.getLocalName( i ), attrs.getValue( i ) ); } if ( this.configurationStack.isEmpty() ) { this.configurationStack.addLast( element ); } else { ((Element) this.configurationStack.getLast()).appendChild( element ); this.configurationStack.addLast( element ); } }
Example #17
Source Project: dragonwell8_jdk Author: alibaba File: SynthParser.java License: GNU General Public License v2.0 | 6 votes |
private void startGraphics(Attributes attributes) throws SAXException { SynthGraphicsUtils graphics = null; for(int i = attributes.getLength() - 1; i >= 0; i--) { String key = attributes.getQName(i); if (key.equals(ATTRIBUTE_IDREF)) { graphics = (SynthGraphicsUtils)lookup(attributes.getValue(i), SynthGraphicsUtils.class); } } if (graphics == null) { throw new SAXException("graphicsUtils: you must supply an idref"); } if (_style != null) { _style.setGraphicsUtils(graphics); } }
Example #18
Source Project: jasperreports Author: TIBCOSoftware File: JRGenericElementFactory.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public Object createObject(Attributes attrs) throws Exception { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); JRDesignGenericElement element = new JRDesignGenericElement(jasperDesign); EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime)); if (evaluationTime != null) { element.setEvaluationTime(evaluationTime); } if (element.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP) { String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup); if (groupName != null) { element.setEvaluationGroupName(groupName); } } return element; }
Example #19
Source Project: autopoi Author: zhangdaiscott File: SheetHandler.java License: Apache License 2.0 | 6 votes |
@Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { // 置空 lastContents = ""; // c => 单元格 if ("c".equals(name)) { // 如果下一个元素是 SST 的索引,则将nextIsString标记为true String cellType = attributes.getValue("t"); if ("s".equals(cellType)) { type = CellValueType.String; return; } // 日期格式 cellType = attributes.getValue("s"); if ("1".equals(cellType)) { type = CellValueType.Date; } else if ("2".equals(cellType)) { type = CellValueType.Number; } } else if ("t".equals(name)) {// 当元素为t时 type = CellValueType.TElement; } }
Example #20
Source Project: kogito-runtimes Author: kiegroup File: DefinitionHandler.java License: Apache License 2.0 | 6 votes |
public Object start(String uri, String localName, Attributes attrs, ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder( localName, attrs ); String packageName = attrs.getValue( "package" ); String name = attrs.getValue( "name" ); emptyAttributeCheck( localName, "package", packageName, parser ); emptyAttributeCheck( localName, "name", name, parser ); DefinitionHandler.DefinitionHandlerData data = new DefinitionHandlerData(packageName, name); return data; }
Example #21
Source Project: tomcatsrc Author: wangyingjie File: MemoryUserDatabase.java License: Apache License 2.0 | 5 votes |
@Override public Object createObject(Attributes attributes) { String groupname = attributes.getValue("groupname"); if (groupname == null) { groupname = attributes.getValue("name"); } String description = attributes.getValue("description"); String roles = attributes.getValue("roles"); Group group = database.createGroup(groupname, description); if (roles != null) { while (roles.length() > 0) { String rolename = null; int comma = roles.indexOf(','); if (comma >= 0) { rolename = roles.substring(0, comma).trim(); roles = roles.substring(comma + 1); } else { rolename = roles.trim(); roles = ""; } if (rolename.length() > 0) { Role role = database.findRole(rolename); if (role == null) { role = database.createRole(rolename, null); } group.addRole(role); } } } return (group); }
Example #22
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: AbstractLDMLHandler.java License: GNU General Public License v2.0 | 5 votes |
private boolean pushIfIgnored(String qName, Attributes attributes) { if (isIgnored(attributes) || currentContainer instanceof IgnoredContainer) { pushIgnoredContainer(qName); return true; } return false; }
Example #23
Source Project: gemfirexd-oss Author: gemxd File: CacheXmlParser.java License: Apache License 2.0 | 5 votes |
/** * When a <code>parition-attributes</code> element is encountered, we push a * ParitionAttributes?? for configuring paritioned storage on the * stack. */ private void startPartitionAttributes(Attributes atts) { PartitionAttributesImpl paf = new PartitionAttributesImpl(); String redundancy = atts.getValue(PARTITION_REDUNDANT_COPIES); if (redundancy != null) { paf.setRedundantCopies(parseInt(redundancy)); } String localMaxMem = atts.getValue(LOCAL_MAX_MEMORY); if (localMaxMem != null) { paf.setLocalMaxMemory(parseInt(localMaxMem)); } String totalMaxMem = atts.getValue(TOTAL_MAX_MEMORY); if (totalMaxMem != null) { paf.setTotalMaxMemory(parseLong(totalMaxMem)); } String totalNumBuckets = atts.getValue(TOTAL_NUM_BUCKETS); if (totalNumBuckets != null) { paf.setTotalNumBuckets(parseInt(totalNumBuckets)); } String colocatedWith = atts.getValue(PARTITION_COLOCATED_WITH); if (colocatedWith != null) { paf.setColocatedWith(colocatedWith); } String recoveryDelay = atts.getValue(RECOVERY_DELAY); if (recoveryDelay != null) { paf.setRecoveryDelay(parseInt(recoveryDelay)); } String startupRecoveryDelay = atts.getValue(STARTUP_RECOVERY_DELAY); if (startupRecoveryDelay != null) { paf.setStartupRecoveryDelay(parseInt(startupRecoveryDelay)); } stack.push(paf); }
Example #24
Source Project: freehealth-connector Author: taktik File: XOPValidationHandler.java License: GNU Affero General Public License v3.0 | 5 votes |
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (this.enabled) { this.resetXOP(); if ("Include".equals(localName) && "http://www.w3.org/2004/08/xop/include".equals(uri) && attributes.getValue("href") != null) { this.xop = true; } } }
Example #25
Source Project: Tomcat7.0.67 Author: tryandcatch File: NodeCreateRule.java License: Apache License 2.0 | 5 votes |
/** * Implemented to replace the content handler currently in use by a * NodeBuilder. * * @param namespaceURI the namespace URI of the matching element, or an * empty string if the parser is not namespace aware or the element has * no namespace * @param name the local name if the parser is namespace aware, or just * the element name otherwise * @param attributes The attribute list of this element * @throws Exception indicates a JAXP configuration problem */ @Override public void begin(String namespaceURI, String name, Attributes attributes) throws Exception { XMLReader xmlReader = getDigester().getXMLReader(); Document doc = documentBuilder.newDocument(); NodeBuilder builder = null; if (nodeType == Node.ELEMENT_NODE) { Element element = null; if (getDigester().getNamespaceAware()) { element = doc.createElementNS(namespaceURI, name); for (int i = 0; i < attributes.getLength(); i++) { element.setAttributeNS(attributes.getURI(i), attributes.getLocalName(i), attributes.getValue(i)); } } else { element = doc.createElement(name); for (int i = 0; i < attributes.getLength(); i++) { element.setAttribute(attributes.getQName(i), attributes.getValue(i)); } } builder = new NodeBuilder(doc, element); } else { builder = new NodeBuilder(doc, doc.createDocumentFragment()); } xmlReader.setContentHandler(builder); }
Example #26
Source Project: jdk8u-jdk Author: lambdalab-mirror File: SynthParser.java License: GNU General Public License v2.0 | 5 votes |
private void startOpaque(Attributes attributes) { if (_style != null) { _style.setOpaque(true); for(int i = attributes.getLength() - 1; i >= 0; i--) { String key = attributes.getQName(i); if (key.equals(ATTRIBUTE_VALUE)) { _style.setOpaque("true".equals(attributes.getValue(i). toLowerCase())); } } } }
Example #27
Source Project: jdk8u-jdk Author: lambdalab-mirror File: MetaZonesParseHandler.java License: GNU General Public License v2.0 | 5 votes |
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { switch (qName) { case "timezone": tzid = attributes.getValue("type"); pushContainer(qName, attributes); break; case "usesMetazone": // Ignore any historical zone names (for now) if (attributes.getValue("to") == null) { metazone = attributes.getValue("mzone"); } pushIgnoredContainer(qName); break; case "version": case "generation": pushIgnoredContainer(qName); break; default: // treat anything else as a container pushContainer(qName, attributes); break; } }
Example #28
Source Project: kogito-runtimes Author: kiegroup File: ValueHandler.java License: Apache License 2.0 | 5 votes |
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder( localName, attrs ); return null; }
Example #29
Source Project: tomcatsrc Author: wangyingjie File: Node.java License: Apache License 2.0 | 5 votes |
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagInfo tagInfo, Class<?> tagHandlerClass) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagInfo = tagInfo; this.tagHandlerClass = tagHandlerClass; this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = IterationTag.class .isAssignableFrom(tagHandlerClass); this.implementsBodyTag = BodyTag.class .isAssignableFrom(tagHandlerClass); this.implementsTryCatchFinally = TryCatchFinally.class .isAssignableFrom(tagHandlerClass); this.implementsSimpleTag = SimpleTag.class .isAssignableFrom(tagHandlerClass); this.implementsDynamicAttributes = DynamicAttributes.class .isAssignableFrom(tagHandlerClass); this.implementsJspIdConsumer = JspIdConsumer.class .isAssignableFrom(tagHandlerClass); }
Example #30
Source Project: netbeans Author: apache File: Hk2MessageDestinationManager.java License: Apache License 2.0 | 5 votes |
@Override public void readChildren(String qname, Attributes attributes) throws SAXException { if (null != attributes && null != properties) { String key = attributes.getValue("name"); // NOI18N if(key != null && key.length() > 0) { properties.put(key.toLowerCase(Locale.ENGLISH), attributes.getValue("value")); // NOI18N } } }