1 package org.sapia.util.xml.parser; 2 3 4 import org.xml.sax.Attributes ; 7 8 9 19 public class ParserUtil { 20 25 public static String toStringAtributes(Attributes someAttributes) { 26 StringBuffer aBuffer = new StringBuffer (); 27 28 for (int i = 0; i < someAttributes.getLength(); i++) { 29 aBuffer.append("Attribute ").append(i).append(":") 30 .append(" qualifiedName=").append(someAttributes.getQName(i)) 31 .append(" namespaceURI=").append(someAttributes.getURI(i)) 32 .append(" localName=").append(someAttributes.getLocalName(i)) 33 .append(" type=").append(someAttributes.getType(i)) 34 .append(" value=").append(someAttributes.getValue(i)).append("\n"); 35 } 36 37 return aBuffer.toString(); 38 } 39 40 45 public static String extractXmlBaseURI(Attributes someAttributes) { 46 String aValue = someAttributes.getValue(XMLDictionnaryIF.QUALIFIED_ELEMENT_XML_BASE); 47 48 if (aValue == null) { 49 aValue = someAttributes.getValue(XMLDictionnaryIF.XML_NAMESPACE_URI, 50 XMLDictionnaryIF.LOCAL_ELEMENT_XML_BASE); 51 } 52 53 return aValue; 54 } 55 56 61 public static String extractXmlLanguageCode(Attributes someAttributes) { 62 String aValue = someAttributes.getValue(XMLDictionnaryIF.QUALIFIED_ELEMENT_XML_LANG); 63 64 if (aValue == null) { 65 aValue = someAttributes.getValue(XMLDictionnaryIF.XML_NAMESPACE_URI, 66 XMLDictionnaryIF.LOCAL_ELEMENT_XML_LANG); 67 } 68 69 return aValue; 70 } 71 72 77 public static String extractXmlSpaceValue(Attributes someAttributes) { 78 String aValue = someAttributes.getValue(XMLDictionnaryIF.QUALIFIED_ELEMENT_XML_SPACE); 79 80 if (aValue == null) { 81 aValue = someAttributes.getValue(XMLDictionnaryIF.XML_NAMESPACE_URI, 82 XMLDictionnaryIF.LOCAL_ELEMENT_XML_SPACE); 83 } 84 85 return aValue; 86 } 87 } 88 | Popular Tags |