|
From: Pelle B. <pe...@us...> - 2004-04-18 01:03:58
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21784/src/java/org/neuclear/xml Modified Files: XMLTools.java Log Message: Added another varient of the id attribute to the getElementById method. Index: XMLTools.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/XMLTools.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XMLTools.java 14 Jan 2004 16:34:27 -0000 1.6 --- XMLTools.java 18 Apr 2004 01:03:48 -0000 1.7 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.7 2004/04/18 01:03:48 pelle + * Added another varient of the id attribute to the getElementById method. + * * Revision 1.6 2004/01/14 16:34:27 pelle * New model of references and signatures now pretty much works. *************** *** 183,193 **** return DocumentHelper.createDocument(); } ! public static Document loadDocument(final String url) throws XMLException{ try { return loadDocument(new URL(url)); } catch (MalformedURLException e) { ! throw new XMLException(e); } } public static Document loadDocument(final URL url) throws XMLException { try { --- 186,198 ---- return DocumentHelper.createDocument(); } ! ! public static Document loadDocument(final String url) throws XMLException { try { return loadDocument(new URL(url)); } catch (MalformedURLException e) { ! throw new XMLException(e); } } + public static Document loadDocument(final URL url) throws XMLException { try { *************** *** 198,201 **** --- 203,207 ---- } } + public static Document loadDocument(final InputStream is) throws XMLException { try { *************** *** 298,326 **** throw new XMLException(e); } /** * This is used to find an Elemente with a given ID. * This is necessary because of Dom4j's use of the ID attribute * and not the more common in XMLSignature Id attribute. * @param elem * @param id * @return */ ! public static Element getByID(Element elem,String id){ ! return getByID(elem.getDocument(),id); } /** * This is used to find an Elemente with a given ID. * This is necessary because of Dom4j's use of the ID attribute * and not the more common in XMLSignature Id attribute. * @param doc * @param id * @return */ ! public static Element getByID(Document doc,String id){ ! Element object=doc.elementByID(id); ! if (object!=null) return object; ! XPath xp=DocumentHelper.createXPath("//*[@Id='"+id+"']"); ! return (Element) xp.selectSingleNode(doc); } --- 304,341 ---- throw new XMLException(e); } + /** * This is used to find an Elemente with a given ID. * This is necessary because of Dom4j's use of the ID attribute * and not the more common in XMLSignature Id attribute. + * * @param elem * @param id * @return */ ! public static Element getByID(Element elem, String id) { ! return getByID(elem.getDocument(), id); } + /** * This is used to find an Elemente with a given ID. * This is necessary because of Dom4j's use of the ID attribute * and not the more common in XMLSignature Id attribute. + * * @param doc * @param id * @return */ ! public static Element getByID(Document doc, String id) { ! Element object = doc.elementByID(id); ! if (object != null) return object; ! XPath xp = DocumentHelper.createXPath("//*[@Id='" + id + "']"); ! object = (Element) xp.selectSingleNode(doc); ! if (object != null) ! return object; ! xp = DocumentHelper.createXPath("//*[@id='" + id + "']"); ! object = (Element) xp.selectSingleNode(doc); ! return object; } |