List of usage examples for org.xml.sax Attributes getValue
public abstract String getValue(String qName);
From source file:net.ontopia.xml.ContentWriter.java
@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { try {/*from w ww . java 2 s .c o m*/ out.write("<" + localName); if (atts != null) { for (int i = 0; i < atts.getLength(); i++) out.write(" " + atts.getQName(i) + "=\"" + escape(atts.getValue(i)) + "\""); } out.write('>'); } catch (IOException e) { throw new SAXException(e); } content = false; }
From source file:com.pontecultural.flashcards.ReadSpreadsheet.java
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { if (qName.equals(TAG_FOR_DECK)) { deckName = atts.getValue(ATTR_TABLE_NAME); } else if (qName.equals(TAG_FOR_CARD)) { inDescription = false;//from w w w.j a v a2 s.co m logger.debug("Commence card"); } else if (qName.equals(TAG_FOR_TEXT)) { if (srcColumnSetP == false) { inSrcLang = true; } else { inDestLang = true; } } }
From source file:net.sf.janos.model.xml.AVTransportEventHandler.java
@Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { /* The events are all of the form <qName val="value"/> so we can get all * the info we need from here./*from w w w .j a va 2s . c o m*/ */ try { AVTransportEventType type = AVTransportEventType.valueOf(localName); changes.put(type, atts.getValue("val")); } catch (IllegalArgumentException e) { // this means that localName isn't defined in EventType, which is expected for some elements LOG.info(localName + " is not defined in EventType. "); } }
From source file:net.sibcolombia.sibsp.model.factory.ThesaurusHandlingRule.java
@Override public void begin(String namespace, String name, Attributes attributes) throws Exception { for (int i = 0; i < attributes.getLength(); i++) { if (ThesaurusHandlingRule.ATTRIBUTE_THESAURUS.equals(attributes.getQName(i))) { Vocabulary tv = null;/*from w w w.jav a 2s . co m*/ try { URI vocabURIObject = new URI(attributes.getValue(i)); tv = vocabManager.get(vocabURIObject); } catch (Exception e) { LOG.error("Vocabulary with location " + attributes.getValue(i) + " couldnt get hold of: " + e.getMessage(), e); } if (tv == null) { LOG.warn("No Vocabulary object exists for the URL[" + attributes.getValue(i) + "] so cannot be set"); } else { Object extensionPropertyAsObject = getDigester().peek(); if (extensionPropertyAsObject instanceof ExtensionProperty) { ExtensionProperty eProperty = (ExtensionProperty) extensionPropertyAsObject; eProperty.setVocabulary(tv); LOG.debug("Vocabulary with URI[" + tv.getUriString() + "] added to extension property"); } } break; // since we found the attribute } } }
From source file:es.mityc.firmaJava.libreria.utilidades.AnalizadorFicheroFirma.java
public void startElement(String espacioNombres, String nomLocal, String nomCompleto, Attributes atrs) { String id = null;/*w w w . j a v a 2 s. c om*/ int longitud = atrs.getLength(); for (int i = 0; i < longitud; i++) { if (ID.equals(atrs.getLocalName(i))) { id = atrs.getValue(i); } } if ((PARTS.equals(nomLocal)) && (PARTS.equals(nomCompleto))) { procesando = true; try { File fichero = File.createTempFile(id + GUION, GUION_TEMPORAL); ficheros.add(fichero); os = new FileOutputStream(fichero); } catch (IOException e) { e.printStackTrace(); } } }
From source file:net.sf.jasperreports.engine.xml.StyleContainerRule.java
@Override public void begin(String namespace, String name, Attributes attributes) throws Exception { DesignStyleContainer styleContainer = (DesignStyleContainer) digester.peek(); JasperDesign jasperDesign = (JasperDesign) digester.peek(digester.getCount() - 2); styleContainer.setDefaultStyleProvider(jasperDesign); String styleName = attributes.getValue(styleAttribute); if (styleName != null) { Map<String, JRStyle> stylesMap = jasperDesign.getStylesMap(); if (stylesMap.containsKey(styleName)) { JRStyle style = stylesMap.get(styleName); styleContainer.setStyle(style); } else {/* w ww . j a v a2 s. c om*/ styleContainer.setStyleNameReference(styleName); } } }
From source file:fr.lip6.move.coloane.projects.its.io.ModelHandler.java
/** * Parse a parameter description//from w ww .j av a2 s . c o m * @param attributes the attributes of the concept in XML * @throws SAXException any parse error */ private void handleParameter(Attributes attributes) throws SAXException { String name = attributes.getValue("name"); //$NON-NLS-1$ int value = Integer.parseInt(attributes.getValue("value")); //$NON-NLS-1$ int idParent = Integer.parseInt(attributes.getValue("parent")); //$NON-NLS-1$ // Get parent with maximum safeguards ITypeDeclaration parent; try { parent = (ITypeDeclaration) ids.get(idParent); } catch (ClassCastException e) { throw new SAXException("Corrupted XML file, id " + idParent + " should refer to a type declaration"); } if (parent == null) { throw new SAXException( "Corrupted XML file, Dangling parent type id " + idParent + " in parameter " + name); } // get the evaluation context IEvaluationContext params = parent.getParameters(); IVariable var = new Variable(name); if (!params.containsVariable(var)) { logger.warning("Concept effective definition which should belong to CompositeType " + parent + " does not exist in the actual model file. Ignoring Concept setting."); } else { params.setVariableValue(var, value); } }
From source file:com.knowledgebooks.rdf.SparqlClient.java
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { //System.out.println("startElement " + qName); if (qName.equalsIgnoreCase("result")) { tempBinding = new HashMap<String, String>(); }//from w ww . ja v a 2 s . co m if (qName.equalsIgnoreCase("binding")) { tempVariableName = attributes.getValue("name"); } lastElementName = qName; }
From source file:com.atlassw.tools.eclipse.checkstyle.builder.PackageNamesLoader.java
/** * {@inheritDoc}// w ww . j a va2s . co m */ public void startElement(String aNamespaceURI, String aLocalName, String aQName, Attributes aAtts) throws SAXException { if (aQName.equals("package")) //$NON-NLS-1$ { // push package name final String name = aAtts.getValue("name"); //$NON-NLS-1$ if (name == null) { throw new SAXException("missing package name"); //$NON-NLS-1$ } mPackageStack.push(name); } }
From source file:fr.lip6.move.coloane.projects.its.io.ModelHandler.java
/** * Parse a concept description//from w ww. jav a 2 s.co m * @param attributes the attributes of the concept in XML * @throws SAXException any parse error */ private void handleConcept(Attributes attributes) throws SAXException { String name = attributes.getValue("name"); //$NON-NLS-1$ int idEffective = Integer.parseInt(attributes.getValue("effective")); //$NON-NLS-1$ int idParent = Integer.parseInt(attributes.getValue("parent")); //$NON-NLS-1$ if (idEffective == -1) { // concept is not assigned return; } // Get parent with maximum safeguards CompositeTypeDeclaration parent; try { parent = (CompositeTypeDeclaration) ids.get(idParent); } catch (ClassCastException e) { throw new SAXException( "Corrupted XML file, id " + idParent + " should refer to a composite type declaration"); } if (parent == null) { throw new SAXException( "Corrupted XML file, Dangling parent type id " + idParent + " in concept " + name); } // Get effective with maximum safeguards ITypeDeclaration effective; try { effective = (ITypeDeclaration) ids.get(idEffective); } catch (ClassCastException e) { throw new SAXException( "Corrupted XML file, effective id " + idEffective + " should refer to a type declaration"); } if (effective == null) { throw new SAXException( "Corrupted XML file, Dangling Effective type id " + idEffective + " in concept " + name); } // get the concept Concept concept = parent.getConcept(name); if (concept == null) { logger.warning("Concept effective definition which should belong to CompositeType " + parent + " does not exist in the actual model file. Ignoring Concept setting."); } else { concept.setEffective(effective); } }