private Attributes getAttributes() { AttributesImpl attributes = new AttributesImpl(); for (int i = 0; i < this.reader.getAttributeCount(); i++) { String namespace = this.reader.getAttributeNamespace(i); if (namespace == null || !hasNamespacesFeature()) { namespace = ""; } String type = this.reader.getAttributeType(i); if (type == null) { type = "CDATA"; } attributes.addAttribute(namespace, this.reader.getAttributeLocalName(i), toQualifiedName(this.reader.getAttributeName(i)), type, this.reader.getAttributeValue(i)); } if (hasNamespacePrefixesFeature()) { for (int i = 0; i < this.reader.getNamespaceCount(); i++) { String prefix = this.reader.getNamespacePrefix(i); String namespaceUri = this.reader.getNamespaceURI(i); String qName; if (StringUtils.hasLength(prefix)) { qName = "xmlns:" + prefix; } else { qName = "xmlns"; } attributes.addAttribute("", "", qName, "CDATA", namespaceUri); } } return attributes; }
public StartElementBuffer( XMLStreamReader rd ) { prefix = rd.getPrefix(); namespace = rd.getNamespaceURI(); localName = rd.getLocalName(); for ( int i = 0; i < rd.getAttributeCount(); i++ ) { attrBuffer.add( new AttrBuffer( rd, i ) ); } }
private Attributes parseAttributes(final XMLStreamReader streamReader) throws RealmUnavailableException, XMLStreamException { final int attributeCount = streamReader.getAttributeCount(); if (attributeCount > 0) { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } int tag = streamReader.nextTag(); if (tag == END_ELEMENT) { return Attributes.EMPTY; } Attributes attributes = new MapAttributes(); do { if (! validNamespace(streamReader.getNamespaceURI())) { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } if ("attribute".equals(streamReader.getLocalName())) { parseAttribute(streamReader, attributes); } else { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } } while (streamReader.nextTag() == START_ELEMENT); return attributes; }
loc = r.getLocation(); } else { loc = mLastLocation; loc = mLastLocation = r.getLocation(); int attrCount = r.getAttributeCount(); if (attrCount < 1) { attrs = null; attrs = new LinkedHashMap(); for (int i = 0; i < attrCount; ++i) { QName aname = r.getAttributeName(i); attrs.put(aname, new AttributeEventImpl(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i))); if (ed == null) { // undefined? return new WEntityReference(loc, r.getLocalName()); return new WEntityReference(loc, r.getLocalName());
private static void parseSubsystem(final XMLStreamReader reader, final Set<String> subsystems) throws XMLStreamException { String name = null; final Set<Attribute> required = EnumSet.of(Attribute.NAME); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); required.remove(attribute); switch (attribute) { case NAME: name = reader.getAttributeValue(i); break; default: throw unexpectedContent(reader); } } if (!required.isEmpty()) { throw missingAttributes(reader.getLocation(), required); } subsystems.add(name); if (reader.hasNext()) { switch (reader.nextTag()) { case XMLStreamConstants.END_ELEMENT: return; default: throw unexpectedContent(reader); } } }
public static Map<QName,String> getAttributes(XMLStreamReader reader) { Map<QName,String> map = new HashMap<QName,String>(); for (int i = 0; i < reader.getAttributeCount(); i++) map.put(reader.getAttributeName(i), reader.getAttributeValue(i)); return map; }
public class Main { public static void main(String args[]) { try{ String raw = "<?xml version='1.0' encoding='iso-8859-1'?><ResDoc><resume canonversion='2' dateversion='2' present='735453' xml:space='preserve'>Jack - A Web ResumeHello,My name is Jack.<statements><personal>This website is all about my career, work experience and skill set. Unlike a traditional resume (available here in Word and PDF) my Web Resume is interactive. Feel free to run a query, a great way to see if I would be a good fit for you and your company, or click on any of the blue links for more details and work samples.Just like my career and capabilities, this site is always growing as I add more examples of my work, and even some blog entries or documentation/ tutorials. You will see this site grow as I do!</personal></statements>I want to thank you for stopping by!Resume<experience>Current employer\t2013\tCurrent\t<title>Systems Administrator</title>\t<description>Windows & Altiris administration, SEP & Credant Encryption Management and Policies,EMR Software Dev company\t2012\t2013\tHelpesk Technician II\tOffice 365,Data-Center migration, Corporate image creation\\ configuration, Domain administrationCommunications\t2011\t2012\tSr. Helpesk Technician\tPrimarily managed IT support issues, requests and tickets from local station & east coast.</description><job id='1'><employer>University\t2008</employer>\t2011\t<title>Desktop Technician/ Analyst\tDesktop Support</title>, <description>managing tickets & walk-ins. I.T. support for professors & faculty..</description></job><job id='2'><employer>Emergence Enterprises LLC</employer>\t2006\t<description>2008\tManaging Member & Technology Consultant\t1099 Contractor in City1 and City 2 areas. Computer consultation and support.Hightlights of IT Skills Don't be shy! Please, click the links for work samples!Technical Support\tSystems Deployment Configuration & Upgrading\tScripting packaging and AutomationPowerShell\tVBScript\tBatchAutoIT\tSQL\tSymantec Management Platform AdministrationPatches & Updates\tTraining & Mentoring\tAV management and deploymentVPN\tProxy and Firewall\tDisk Encryption policy and deploymentLAN/WAN Administration\tInventory Solutions\tand More!</description></job></experience>ReferencesRef_1\tSystems Engineer II\tnationwide companyRef_2\tTechnology & Systems Manager\tUniversityRef_3\tInfrastructure Project Manager\tLocal company</resume><skillrollup version='1'> <canonskill experience='1' expidrefs='2' idrefs='2' name='automation'> <variant>Automation</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='consulting'> <variant>Consultant</variant> <variant>consultation</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='cryptography'> <variant>Encryption</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='firewalls'> <variant>Firewall</variant> </canonskill> <canonskill experience='1' name='imaging'> <variant>image</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='inventory management'> <variant>Inventory</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='lan'> <variant>LAN</variant> </canonskill> <canonskill experience='1' expidrefs='1,2' idrefs='1,2' name='management'> <variant>Managing</variant> <variant>managing</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='mentoring'> <variant>Mentoring</variant> </canonskill> <canonskill experience='1' name='microsoft office'> <variant>Office</variant> </canonskill> <canonskill experience='1' name='microsoft windows'> <variant>Windows</variant> </canonskill> <canonskill experience='1' name='migration'> <variant>migration</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='packaging'> <variant>packaging</variant> </canonskill> <canonskill experience='1' name='policy analysis'> <variant>Policies</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='proxy server'> <variant>Proxy</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='shell scripting'> <variant>Scripting</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='sql'> <variant>SQL</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='symantec packages'> <variant>Symantec</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='technical support'> <variant>Technical Support</variant> </canonskill> <canonskill experience='1' name='technician'> <variant>Technician</variant> <variant>Technician II</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='upgrades'> <variant>Upgrading</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='vbscript'> <variant>VBScript</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='vpn'> <variant>VPN</variant> </canonskill> <canonskill experience='1' expidrefs='2' idrefs='2' name='wan'> <variant>WAN</variant> </canonskill></skillrollup></ResDoc>"; XMLInputFactory xif = XMLInputFactory.newFactory(); XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(raw)); while(xsr.hasNext()){ xsr.nextTag(); System.out.println(xsr.getName()); System.out.println(xsr.getAttributeCount()); } } catch(XMLStreamException e) { } } }
for ( int event = vReader.next(); vReader.hasNext(); event = vReader.next() ) { switch ( event ) { case XMLStreamConstants.START_ELEMENT: logRowlevel( "START_ELEMENT / " + vReader.getAttributeCount() + " / " + vReader.getNamespaceCount() ); logRowlevel( "vReader.getLocalName = " + vReader.getLocalName() ); WebServiceField field = meta.getFieldOutFromWsName( vReader.getLocalName(), ignoreNamespacePrefix ); if ( field != null ) { outputRowData[ outputIndex++ ] = getValue( vReader.getElementText(), field ); oneValueRowProcessing = false; } else { if ( meta.getOutFieldContainerName().equals( vReader.getLocalName() ) ) {
private String findFirstAttributeValue(XMLStreamReader reader, String name) { for (int i = 0; i < reader.getAttributeCount(); i++) { String n = reader.getAttributeLocalName(i); if (name.equals(n)) { return reader.getAttributeValue(i); } } return ""; }
protected static void processResource(final XMLStreamReader reader, final Set<String> resources) throws XMLStreamException { final int attributeCount = reader.getAttributeCount(); if (attributeCount != 1) { throw new XMLStreamException(); } final String path = reader.getAttributeValue(0); resources.add(path.trim()); if (reader.hasNext() && reader.nextTag() != END_ELEMENT) { throw new XMLStreamException("unexpected element"); } }
FileInputStream xmlStream = new FileInputStream(new File("myxml.xml")); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(xmlStream); while(reader.hasNext()){ reader.next(); for(int i=0; i < reader.getAttributeCount(); i++) { System.out.println(reader.getAttributeName(i) + "=" + reader.getAttributeValue(i)); } }
private void parseCredential(final XMLStreamReader streamReader, CredentialParseFunction function) throws RealmUnavailableException, XMLStreamException { final int attributeCount = streamReader.getAttributeCount(); String name = null; String algorithm = null; String format = null; for (int i = 0; i < attributeCount; i ++) { String namespace = streamReader.getAttributeNamespace(i); if (namespace != null && !namespace.equals("")) { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } final String localName = streamReader.getAttributeLocalName(i); if ("name".equals(localName)) { name = streamReader.getAttributeValue(i); } else if ("algorithm".equals(localName)) { algorithm = streamReader.getAttributeValue(i); } else if ("format".equals(localName)) { format = streamReader.getAttributeValue(i); } else { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } } final String text = streamReader.getElementText().trim(); function.parseCredential(algorithm, format, text); }
private static void StAXStartElement(XMLStreamReader r, Stack<TokenNode> stack, String filePath) { String name = r.getLocalName(); TokenNode n = new TokenNode(name); n.setFilePath(filePath); stack.push(n); int len = r.getAttributeCount(); for (int i = 0; i < len; i++) { String k = r.getAttributeName(i).getLocalPart(); String v = r.getAttributeValue(i); n.putAttr(k, v); } }
private static void parseSubsystem(final XMLStreamReader reader, final Set<String> subsystems) throws XMLStreamException { String name = null; final Set<Attribute> required = EnumSet.of(Attribute.NAME); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); required.remove(attribute); switch (attribute) { case NAME: name = reader.getAttributeValue(i); break; default: throw unexpectedContent(reader); } } if (!required.isEmpty()) { throw missingAttributes(reader.getLocation(), required); } subsystems.add(name); if (reader.hasNext()) { switch (reader.nextTag()) { case XMLStreamConstants.END_ELEMENT: return; default: throw unexpectedContent(reader); } } }
private Map<String, String> parseAttributes() { int num = parser.getAttributeCount(); Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i < num; i++) { map.put(parser.getAttributeName(i).getLocalPart(), parser.getAttributeValue(i)); } return map; }
private List<Credential> parseCredentials(final XMLStreamReader streamReader) throws RealmUnavailableException, XMLStreamException { final int attributeCount = streamReader.getAttributeCount(); if (attributeCount > 0) { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } if (streamReader.nextTag() == END_ELEMENT) { return Collections.emptyList(); } List<Credential> credentials = new ArrayList<>(); do { if (! validNamespace(streamReader.getNamespaceURI())) { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } if ("password".equals(streamReader.getLocalName())) { parsePassword(credentials, streamReader); } else if ("public-key".equals(streamReader.getLocalName())) { parsePublicKey(credentials, streamReader); } else if ("certificate".equals(streamReader.getLocalName())) { parseCertificate(credentials, streamReader); } else if ("otp".equals(streamReader.getLocalName())) { parseOtp(credentials, streamReader); } else { throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name); } } while (streamReader.nextTag() != END_ELEMENT); return credentials; }
public ApplicationClientMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { reader.require(START_DOCUMENT, null, null); // Read until the first start element while (reader.hasNext() && reader.next() != START_ELEMENT) {} final ApplicationClientMetaData appClientMetadata = new ApplicationClientMetaData(); // Handle attributes and set them in the EjbJarMetaData final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { if (attributeHasNamespace(reader, i)) { continue; } processAttribute(appClientMetadata, reader, i); } appClientMetadata.setDescriptionGroup(new DescriptionGroupMetaData()); appClientMetadata.setEnvironmentRefsGroupMetaData(new AppClientEnvironmentRefsGroupMetaData()); // parse and create metadata out of the elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { processElement(appClientMetadata, reader, propertyReplacer); } return appClientMetadata; }
/*package*/ void fillAttributes(XMLStreamReader in) { for( int i=in.getAttributeCount()-1; i>=0; i-- ) { String n = in.getAttributeLocalName(i); if(model.attributes.containsKey(n)) { if(attributes==null) attributes = new HashMap<String, String>(); attributes.put(n,in.getAttributeValue(i)); } } if(attributes==null) attributes = Collections.emptyMap(); }
private void storeElement(XMLStreamReader reader) { storeQualifiedName(T_ELEMENT_LN, reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName()); if (reader.getNamespaceCount() > 0) { storeNamespaceAttributes(reader); } if (reader.getAttributeCount() > 0) { storeAttributes(reader); } }
private Attributes getAttributes() { AttributesImpl attributes = new AttributesImpl(); for (int i = 0; i < this.reader.getAttributeCount(); i++) { String namespace = this.reader.getAttributeNamespace(i); if (namespace == null || !hasNamespacesFeature()) { namespace = ""; } String type = this.reader.getAttributeType(i); if (type == null) { type = "CDATA"; } attributes.addAttribute(namespace, this.reader.getAttributeLocalName(i), toQualifiedName(this.reader.getAttributeName(i)), type, this.reader.getAttributeValue(i)); } if (hasNamespacePrefixesFeature()) { for (int i = 0; i < this.reader.getNamespaceCount(); i++) { String prefix = this.reader.getNamespacePrefix(i); String namespaceUri = this.reader.getNamespaceURI(i); String qName; if (StringUtils.hasLength(prefix)) { qName = "xmlns:" + prefix; } else { qName = "xmlns"; } attributes.addAttribute("", "", qName, "CDATA", namespaceUri); } } return attributes; }