Changeset 36
- Timestamp:
- 08/02/05 22:59:57 (3 years ago)
- Files:
-
- trunk/src/net/schst/XJConf/Extension.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/Tag.java (modified) (2 diffs)
- trunk/src/net/schst/XJConf/XmlReader.java (modified) (1 diff)
- trunk/src/net/schst/XJConf/ext/XInclude.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/net/schst/XJConf/Extension.java
r32 r36 35 35 * @throws XJConfException 36 36 */ 37 public voidendElement(XmlReader reader, Tag tag)37 public Object endElement(XmlReader reader, Tag tag) 38 38 throws XJConfException; 39 39 } trunk/src/net/schst/XJConf/Tag.java
r32 r36 87 87 } 88 88 89 /** 90 * Check, whether the tag has a certain attribute 91 * 92 * @param name 93 * @return 94 */ 89 95 public boolean hasAttribute(String name) { 90 96 return this.atts.containsKey(name); … … 110 116 } 111 117 118 /** 119 * Get the child with a specific name 120 * 121 * @param name 122 * @return 123 */ 112 124 public Tag getChild(String name) { 113 125 for (Iterator iter = this.children.iterator(); iter.hasNext();) { trunk/src/net/schst/XJConf/XmlReader.java
r34 r36 283 283 Tag tag = (Tag)this.tagStack.pop(); 284 284 285 286 285 if (this.extensions.containsKey(namespaceURI)) { 287 ((Extension)(this.extensions.get(namespaceURI))).endElement(this, tag);286 Object result = ((Extension)(this.extensions.get(namespaceURI))).endElement(this, tag); 288 287 } else { 289 288 if (this.depth == 1) { trunk/src/net/schst/XJConf/ext/XInclude.java
r33 r36 26 26 return this.namespace; 27 27 } 28 29 /* (non-Javadoc) 30 * @see net.schst.XJConf.Extension#endElement(java.lang.String, java.lang.String) 31 */ 32 public void endElement(XmlReader reader, Tag tag) 33 throws XIncludeException { 34 String href = tag.getAttribute("href"); 35 if (href == null) { 36 return; 37 } 38 39 if (!href.startsWith("/")) { 40 File current = reader.getCurrentFile(); 41 href = current.getParent() + "/" + href; 42 } 43 try { 44 reader.parse(href); 45 } catch (Exception e) { 46 throw new XIncludeException("Could not xInclude " + href, e); 47 } 48 } 49 50 /* (non-Javadoc) 51 * @see net.schst.XJConf.Extension#startElement(java.lang.String, org.xml.sax.Attributes) 28 29 /** 30 * Handle an opening tag. 31 * 32 * Currently this does not do anything. 33 * 34 * Future versions should check, whether the file exists and skip all 35 * child elements. 52 36 */ 53 37 public void startElement(XmlReader reader, Tag tag) { 54 38 } 39 40 /** 41 * Handle a closing tag. 42 * 43 * Does the actual x-include. 44 */ 45 public Object endElement(XmlReader reader, Tag tag) 46 throws XIncludeException { 47 48 if (tag.getName().equals("include")) { 49 String href = tag.getAttribute("href"); 50 if (href == null) { 51 return null; 52 } 53 54 if (!href.startsWith("/")) { 55 File current = reader.getCurrentFile(); 56 href = current.getParent() + "/" + href; 57 } 58 try { 59 reader.parse(href); 60 } catch (Exception e) { 61 throw new XIncludeException("Could not xInclude " + href, e); 62 } 63 } 64 return null; 65 } 55 66 }
