You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by hi...@apache.org on 2002/04/29 14:25:06 UTC
cvs commit: xml-batik/sources/org/apache/batik/dom/svg SVGStyleSheetProcessingInstruction.java
hillion 02/04/29 05:25:05
Modified: sources/org/apache/batik/css/engine CSSEngine.java
sources/org/apache/batik/css/engine/value
AbstractValueFactory.java
sources/org/apache/batik/dom/svg
SVGStyleSheetProcessingInstruction.java
Log:
Modified Batik's CSS to used ParsedURL.
Revision Changes Path
1.10 +24 -1 xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java
Index: CSSEngine.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CSSEngine.java 15 Apr 2002 17:01:44 -0000 1.9
+++ CSSEngine.java 29 Apr 2002 12:25:05 -0000 1.10
@@ -58,7 +58,7 @@
* This is the base class for all the CSS engines.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: CSSEngine.java,v 1.9 2002/04/15 17:01:44 hillion Exp $
+ * @version $Id: CSSEngine.java,v 1.10 2002/04/29 12:25:05 hillion Exp $
*/
public abstract class CSSEngine {
@@ -796,6 +796,29 @@
throw new DOMException(DOMException.SYNTAX_ERR, s);
}
parseStyleSheet(ss, uri);
+ return ss;
+ }
+
+ /**
+ * Parses and creates a new style-sheet.
+ * @param is The input source used to read the document.
+ * @param uri The base URI.
+ * @param media The target media of the style-sheet.
+ */
+ public StyleSheet parseStyleSheet(InputSource is, URL uri, String media)
+ throws DOMException {
+ StyleSheet ss = new StyleSheet();
+ try {
+ ss.setMedia(parser.parseMedia(media));
+ parseStyleSheet(ss, is, uri);
+ } catch (Exception e) {
+ String m = e.getMessage();
+ String s =
+ Messages.formatMessage("syntax.error.at",
+ new Object[] { documentURI.toString(),
+ (m == null) ? "" : m });
+ throw new DOMException(DOMException.SYNTAX_ERR, s);
+ }
return ss;
}
1.2 +4 -7 xml-batik/sources/org/apache/batik/css/engine/value/AbstractValueFactory.java
Index: AbstractValueFactory.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/value/AbstractValueFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractValueFactory.java 18 Mar 2002 10:28:22 -0000 1.1
+++ AbstractValueFactory.java 29 Apr 2002 12:25:05 -0000 1.2
@@ -8,18 +8,19 @@
package org.apache.batik.css.engine.value;
-import java.net.MalformedURLException;
import java.net.URL;
import org.w3c.css.sac.LexicalUnit;
import org.w3c.dom.DOMException;
+import org.apache.batik.util.ParsedURL;
+
/**
* This class provides a base implementation for the value factories.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractValueFactory.java,v 1.1 2002/03/18 10:28:22 hillion Exp $
+ * @version $Id: AbstractValueFactory.java,v 1.2 2002/04/29 12:25:05 hillion Exp $
*/
public abstract class AbstractValueFactory {
@@ -32,11 +33,7 @@
* Resolves an URI.
*/
protected static String resolveURI(URL base, String value) {
- try {
- value = new URL(base, value).toString();
- } catch (MalformedURLException e) {
- }
- return value;
+ return new ParsedURL(base, value).toString();
}
/**
1.3 +21 -14 xml-batik/sources/org/apache/batik/dom/svg/SVGStyleSheetProcessingInstruction.java
Index: SVGStyleSheetProcessingInstruction.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGStyleSheetProcessingInstruction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SVGStyleSheetProcessingInstruction.java 18 Mar 2002 10:28:26 -0000 1.2
+++ SVGStyleSheetProcessingInstruction.java 29 Apr 2002 12:25:05 -0000 1.3
@@ -21,6 +21,10 @@
import org.apache.batik.dom.util.HashTable;
+import org.apache.batik.util.ParsedURL;
+
+import org.w3c.css.sac.InputSource;
+
import org.w3c.dom.Node;
/**
@@ -28,7 +32,7 @@
* instructions.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: SVGStyleSheetProcessingInstruction.java,v 1.2 2002/03/18 10:28:26 hillion Exp $
+ * @version $Id: SVGStyleSheetProcessingInstruction.java,v 1.3 2002/04/29 12:25:05 hillion Exp $
*/
public class SVGStyleSheetProcessingInstruction
extends StyleSheetProcessingInstruction
@@ -80,21 +84,24 @@
String type = (String)attrs.get("type");
if ("text/css".equals(type)) {
+ String title = (String)attrs.get("title");
+ String media = (String)attrs.get("media");
+ String href = (String)attrs.get("href");
+ String alternate = (String)attrs.get("alternate");
+ SVGOMDocument doc = (SVGOMDocument)getOwnerDocument();
+ URL durl = doc.getURLObject();
+ URL burl = durl;
try {
- String title = (String)attrs.get("title");
- String media = (String)attrs.get("media");
- String href = (String)attrs.get("href");
- String alternate = (String)attrs.get("alternate");
- SVGOMDocument doc = (SVGOMDocument)getOwnerDocument();
- URL url = doc.getURLObject();
- CSSEngine e = doc.getCSSEngine();
- styleSheet = e.parseStyleSheet(new URL(url, href), media);
- styleSheet.setAlternate("yes".equals(alternate));
- styleSheet.setTitle(title);
- } catch (MalformedURLException e) {
- // !!! TODO exception handling.
- e.printStackTrace();
+ burl = new URL(durl, href);
+ } catch (Exception ex) {
}
+ CSSEngine e = doc.getCSSEngine();
+ styleSheet = e.parseStyleSheet
+ (new InputSource(new ParsedURL(durl, href).toString()),
+ burl,
+ media);
+ styleSheet.setAlternate("yes".equals(alternate));
+ styleSheet.setTitle(title);
}
}
return styleSheet;
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org