[Yanel-commits] rev 44432 - public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation

guillaume at wyona.com guillaume at wyona.com
Thu Aug 27 12:33:23 CEST 2009


Author: guillaume
Date: 2009-08-27 12:33:22 +0200 (Thu, 27 Aug 2009)
New Revision: 44432

Modified:
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/XIncludeTransformer.java
Log:
XInclude inclusions with relative URLs should now also work (untested),
 similarly to XSLT includes and imports as done in revision 44431.

Issue: 6382


Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/XIncludeTransformer.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/XIncludeTransformer.java	2009-08-27 10:24:58 UTC (rev 44431)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/XIncludeTransformer.java	2009-08-27 10:33:22 UTC (rev 44432)
@@ -3,7 +3,7 @@
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.sax.SAXSource;
 
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
 import org.apache.xml.resolver.tools.CatalogResolver;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -11,15 +11,15 @@
 import org.xml.sax.helpers.XMLReaderFactory;
 
 /**
- * Transformer to include xml into a sax stream.
+ * Transformer to include XML into a SAX stream.
  * It will resolve <xi:include href="bla.xml"/>. 
- * The namespace uri is http://www.w3.org/2001/XInclude
- * This is not a complete implementation of the xinclude specification.
+ * The namespace-URI is http://www.w3.org/2001/XInclude
+ * This is not a complete implementation of the XInclude specification.
  * Also see http://www.w3.org/TR/xinclude/
  */
 public class XIncludeTransformer extends AbstractTransformer {
 
-    private static Category log = Category.getInstance(XIncludeTransformer.class);
+    private static final Logger log = Logger.getLogger(XIncludeTransformer.class);
 
     public static final String NS_URI = "http://www.w3.org/2001/XInclude";
     
@@ -36,18 +36,21 @@
         this.resolver = resolver;
     }
 
+    @Override
     public void startDocument() throws SAXException {
         if (!this.ignoreDocumentEvent) {
             super.startDocument();
         }
     }
-    
+
+    @Override
     public void endDocument() throws SAXException {
         if (!this.ignoreDocumentEvent) {
             super.endDocument();
         }
     }
-    
+
+    @Override
     public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {
         
         if (namespaceURI.equals(NS_URI) && localName.equals("include")) {
@@ -61,7 +64,7 @@
             
             this.ignoreDocumentEvent = true;
             try {
-                xmlReader.parse(SAXSource.sourceToInputSource(resolver.resolve(href, null)));
+                xmlReader.parse(SAXSource.sourceToInputSource(resolver.resolve(href, href)));
             } catch (Exception e) {
                 log.error("XInclude error for href: " + href + ":  " + e, e);
                 throw new SAXException(e);
@@ -76,6 +79,7 @@
         }
     }
 
+    @Override
     public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
         if (!this.insideIncludeElement) {
             super.endElement(namespaceURI, localName, qName);



More information about the Yanel-commits mailing list