hillion 01/10/18 05:30:23
Modified: sources/org/apache/batik/bridge
SVGAltGlyphElementBridge.java SVGFontUtilities.java
URIResolver.java
sources/org/apache/batik/css AbstractViewCSS.java
CSSOMStyleRule.java HiddenChildElement.java
HiddenChildElementSupport.java
sources/org/apache/batik/dom
StyleSheetProcessingInstruction.java
sources/org/apache/batik/dom/svg AbstractElement.java
SVGOMDocument.java XMLBaseSupport.java
Added: sources/org/apache/batik/css ExtendedLinkStyle.java
sources/org/apache/batik/dom/svg
SVGStyleSheetProcessingInstruction.java
Log:
Base URIs now supported in CSS.
Revision Changes Path
1.8 +3 -3
xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java
Index: SVGAltGlyphElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SVGAltGlyphElementBridge.java 2001/10/12 07:33:09 1.7
+++ SVGAltGlyphElementBridge.java 2001/10/18 12:30:22 1.8
@@ -28,7 +28,7 @@
* Bridge class for the <altGlyph> element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a>
- * @version $Id: SVGAltGlyphElementBridge.java,v 1.7 2001/10/12 07:33:09 hillion
Exp $
+ * @version $Id: SVGAltGlyphElementBridge.java,v 1.8 2001/10/18 12:30:22 hillion
Exp $
*/
public class SVGAltGlyphElementBridge extends AbstractSVGBridge
implements ErrorConstants {
@@ -103,7 +103,7 @@
if (!isLocal) {
// need to attach the imported element to the document and
// then compute the styles and uris
- String base = XMLBaseSupport.getXMLBase(altGlyphElement);
+ String base = XMLBaseSupport.getCascadedXMLBase(altGlyphElement);
Element g = document.createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG);
g.appendChild(localRefElement);
g.setAttributeNS(XMLBaseSupport.XML_NAMESPACE_URI,
@@ -253,7 +253,7 @@
// import the whole font
Element localFontElement
= (Element)document.importNode(refGlyphElement.getParentNode(),
true);
- String base = XMLBaseSupport.getXMLBase(altGlyphElement);
+ String base = XMLBaseSupport.getCascadedXMLBase(altGlyphElement);
Element g = document.createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG);
g.appendChild(localFontElement);
g.setAttributeNS(XMLBaseSupport.XML_NAMESPACE_URI,
1.8 +2 -2 xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java
Index: SVGFontUtilities.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SVGFontUtilities.java 2001/10/12 07:33:09 1.7
+++ SVGFontUtilities.java 2001/10/18 12:30:22 1.8
@@ -28,7 +28,7 @@
* Utility class for SVG fonts.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a>
- * @version $Id: SVGFontUtilities.java,v 1.7 2001/10/12 07:33:09 hillion Exp $
+ * @version $Id: SVGFontUtilities.java,v 1.8 2001/10/18 12:30:22 hillion Exp $
*/
public abstract class SVGFontUtilities implements SVGConstants {
@@ -134,7 +134,7 @@
fontElement = (isLocal) ? refElement
: (Element)document.importNode(refElement,
true);
if (!isLocal) {
- String base =
XMLBaseSupport.getXMLBase(fontFaceUriElement);
+ String base =
XMLBaseSupport.getCascadedXMLBase(fontFaceUriElement);
// need to attach the imported
// element to the document and
// then compute the styles and
1.12 +2 -2 xml-batik/sources/org/apache/batik/bridge/URIResolver.java
Index: URIResolver.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/URIResolver.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- URIResolver.java 2001/10/15 14:50:23 1.11
+++ URIResolver.java 2001/10/18 12:30:22 1.12
@@ -28,7 +28,7 @@
* This class is used to resolve the URI that can be found in a SVG document.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: URIResolver.java,v 1.11 2001/10/15 14:50:23 deweese Exp $
+ * @version $Id: URIResolver.java,v 1.12 2001/10/18 12:30:22 hillion Exp $
*/
public class URIResolver {
/**
@@ -87,7 +87,7 @@
public Node getNode(String uri, Element ref)
throws MalformedURLException, IOException {
- String baseURI = XMLBaseSupport.getXMLBase(ref);
+ String baseURI = XMLBaseSupport.getCascadedXMLBase(ref);
if ((baseURI == null) &&
(uri.startsWith("#")))
return document.getElementById(uri.substring(1));
1.20 +93 -29 xml-batik/sources/org/apache/batik/css/AbstractViewCSS.java
Index: AbstractViewCSS.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/AbstractViewCSS.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- AbstractViewCSS.java 2001/10/17 14:47:26 1.19
+++ AbstractViewCSS.java 2001/10/18 12:30:22 1.20
@@ -9,6 +9,10 @@
package org.apache.batik.css;
import java.lang.ref.SoftReference;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -17,6 +21,7 @@
import org.apache.batik.css.sac.ExtendedSelector;
import org.apache.batik.css.value.ImmutableInherit;
+import org.apache.batik.css.value.ImmutableString;
import org.apache.batik.css.value.RelativeValueResolver;
import org.apache.batik.util.SoftDoublyIndexedTable;
@@ -26,6 +31,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.css.CSSImportRule;
import org.w3c.dom.css.CSSMediaRule;
+import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleDeclaration;
@@ -45,7 +51,7 @@
* {@link org.w3c.dom.css.ViewCSS} interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: AbstractViewCSS.java,v 1.19 2001/10/17 14:47:26 hillion Exp $
+ * @version $Id: AbstractViewCSS.java,v 1.20 2001/10/18 12:30:22 hillion Exp $
*/
public abstract class AbstractViewCSS implements ViewCSS {
@@ -174,7 +180,7 @@
String pseudoElt) {
CSSOMReadOnlyStyleDeclaration result;
if (elt instanceof HiddenChildElement) {
- result = ((HiddenChildElement)elt).getCascadedStyle();
+ result = ((HiddenChildElement)elt).getStyleDeclaration();
if (result != null) {
return new CSSOMReadOnlyStyleDeclaration(result);
}
@@ -195,10 +201,19 @@
addUserAgentProperties(elt, pseudoElt, result);
addUserProperties(elt, pseudoElt, result);
- addNonCSSPresentationalHints(elt, pseudoElt, result);
+
+ URL baseURI = null;
+ if (elt instanceof ElementWithBaseURI) {
+ try {
+ baseURI = new URL(((ElementWithBaseURI)elt).getBaseURI());
+ } catch (MalformedURLException e) {
+ }
+ }
+
+ addNonCSSPresentationalHints(elt, pseudoElt, baseURI, result);
addAuthorStyleSheetProperties(elt, pseudoElt, result);
- addInlineStyleProperties(elt, pseudoElt, result);
- addOverrideStyleProperties(elt, pseudoElt, result);
+ addInlineStyleProperties(elt, pseudoElt, baseURI, result);
+ addOverrideStyleProperties(elt, pseudoElt, baseURI, result);
return result;
}
@@ -258,7 +273,7 @@
if (userAgentStyleSheet != null) {
addMatchingRules(userAgentStyleSheet.getCssRules(), e, pe,
- uaRules);
+ null, uaRules);
uaRules = sortRules(uaRules, e, pe);
for (int i = 0; i < uaRules.getLength(); i++) {
CSSStyleRule rule = (CSSStyleRule)uaRules.item(i);
@@ -302,7 +317,7 @@
CSSOMRuleList uaRules = new CSSOMRuleList();
if (userStyleSheet != null) {
- addMatchingRules(userStyleSheet.getCssRules(), e, pe, uaRules);
+ addMatchingRules(userStyleSheet.getCssRules(), e, pe, null, uaRules);
uaRules = sortRules(uaRules, e, pe);
for (int i = 0; i < uaRules.getLength(); i++) {
CSSStyleRule rule = (CSSStyleRule)uaRules.item(i);
@@ -340,7 +355,7 @@
* @param rd The result style declaration.
*/
protected void addNonCSSPresentationalHints
- (Element e, String pe, CSSOMReadOnlyStyleDeclaration rd) {
+ (Element e, String pe, URL buri, CSSOMReadOnlyStyleDeclaration rd) {
if ((pe == null || pe.equals("")) &&
e instanceof ElementNonCSSPresentationalHints) {
ElementNonCSSPresentationalHints elt;
@@ -350,7 +365,7 @@
if (nonCSSDecl != null) {
int len = nonCSSDecl.getLength();
for (int i = 0; i < len; i++) {
- setAuthorProperty(nonCSSDecl.item(i), nonCSSDecl, rd);
+ setAuthorProperty(nonCSSDecl.item(i), nonCSSDecl, buri, rd);
}
}
}
@@ -371,19 +386,38 @@
for (int i = 0; i < l.getLength(); i++) {
CSSStyleSheet ss = (CSSStyleSheet)l.item(i);
if (!ss.getDisabled() && mediaMatch(ss.getMedia())) {
+ Node on = ss.getOwnerNode();
+ URL baseURI = null;
+ if (on == null) {
+ if (e instanceof ElementWithBaseURI) {
+ try {
+ baseURI =
+ new URL(((ElementWithBaseURI)e).getBaseURI());
+ } catch (MalformedURLException ex) {
+ }
+ }
+ } else if (on instanceof ExtendedLinkStyle) {
+ try {
+ baseURI =
+ new URL(((ExtendedLinkStyle)on).getStyleSheetURI());
+ } catch (MalformedURLException ex) {
+ }
+ }
addMatchingRules(ss.getCssRules(),
e,
pe,
+ baseURI,
authorRules);
}
}
authorRules = sortRules(authorRules, e, pe);
for (int i = 0; i < authorRules.getLength(); i++) {
- CSSStyleRule rule = (CSSStyleRule)authorRules.item(i);
+ CSSOMStyleRule rule = (CSSOMStyleRule)authorRules.item(i);
+ URL baseURI = rule.getBaseURI();
CSSStyleDeclaration decl = rule.getStyle();
int len = decl.getLength();
for (int j = 0; j < len; j++) {
- setAuthorProperty(decl.item(j), decl, rd);
+ setAuthorProperty(decl.item(j), decl, baseURI, rd);
}
}
} catch (DOMException ex) {
@@ -397,10 +431,12 @@
* Adds the inline style properties to the given style declaration.
* @param e The element to match.
* @param pe The pseudo-element to match.
+ * @param buri The base uri, if any.
* @param rd The result style declaration.
*/
protected void addInlineStyleProperties(Element e,
String pe,
+ URL buri,
CSSOMReadOnlyStyleDeclaration rd) {
try {
if (e instanceof ElementCSSInlineStyle) {
@@ -414,7 +450,7 @@
inlineDecl = ((ElementCSSInlineStyle)e).getStyle();
int len = inlineDecl.getLength();
for (int i = 0; i < len; i++) {
- setAuthorProperty(inlineDecl.item(i), inlineDecl, rd);
+ setAuthorProperty(inlineDecl.item(i), inlineDecl, buri, rd);
}
}
}
@@ -429,17 +465,18 @@
* Adds the override style properties to the given style declaration.
* @param e The element to match.
* @param pe The pseudo-element to match.
+ * @param buri The base uri, if any.
* @param rd The result style declaration.
*/
protected void addOverrideStyleProperties
- (Element e, String pe, CSSOMReadOnlyStyleDeclaration rd) {
+ (Element e, String pe, URL buri, CSSOMReadOnlyStyleDeclaration rd) {
CSSStyleDeclaration overrideDecl;
overrideDecl = ((DocumentCSS)document).getOverrideStyle(e, pe);
if ((pe == null || pe.equals("")) &&
overrideDecl != null) {
int len = overrideDecl.getLength();
for (int i = 0; i < len; i++) {
- setAuthorProperty(overrideDecl.item(i), overrideDecl, rd);
+ setAuthorProperty(overrideDecl.item(i), overrideDecl, buri, rd);
}
}
}
@@ -448,10 +485,12 @@
* Sets a author value to a computed style declaration.
* @param name The property name.
* @param decl The style declaration.
+ * @param buri The base uri, if any.
* @param dest The result style declaration.
*/
protected void setAuthorProperty(String name,
CSSStyleDeclaration decl,
+ URL buri,
CSSOMReadOnlyStyleDeclaration dest) {
CSSOMValue val = (CSSOMValue)decl.getPropertyCSSValue(name);
String prio = decl.getPropertyPriority(name);
@@ -464,21 +503,30 @@
if (dval == null ||
dorg != CSSOMReadOnlyStyleDeclaration.USER_ORIGIN ||
dprio.length() == 0) {
- /*
- if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
- if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
+ resolveURI(value, buri);
+ dest.setPropertyCSSValue(name,
+ value,
+ prio,
+ CSSOMReadOnlyStyleDeclaration.AUTHOR_ORIGIN);
+ }
+ }
+
+ /**
+ * If 'value' is an CSS_URI, resolves the value, relative to the given
+ * URI.
+ */
+ protected void resolveURI(CSSOMReadOnlyValue value, URL buri) {
+ if (buri != null &&
+ value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
+ try {
value.setImmutableValue
(new ImmutableString
(CSSPrimitiveValue.CSS_URI,
- new ParsedURL(basePURL,
- value.getStringValue()).toString()));
+ new URL(buri, value.getStringValue()).toString()));
+ } catch (MalformedURLException e) {
}
}
- */
- dest.setPropertyCSSValue(name,
- value,
- prio,
- CSSOMReadOnlyStyleDeclaration.AUTHOR_ORIGIN);
}
}
@@ -488,11 +536,13 @@
* @param l The input rule list.
* @param e The element to match.
* @param pe The pseudo-element to match.
+ * @param buri The base uri, if any.
* @param rl The result rule list.
*/
protected void addMatchingRules(CSSRuleList l,
Element e,
String pe,
+ URL buri,
CSSOMRuleList rl) {
int llen = l.getLength();
for (int i = 0; i < llen; i++) {
@@ -505,21 +555,35 @@
for (int j = 0; j < slen; j++) {
ExtendedSelector s = (ExtendedSelector)sl.item(j);
if (s.match(e, pe)) {
+ sr.setBaseURI(buri);
rl.append(rule);
}
}
break;
+
case CSSRule.IMPORT_RULE:
CSSImportRule ir = (CSSImportRule)rule;
- CSSStyleSheet is = ir.getStyleSheet();
- if (is != null) {
- addMatchingRules(is.getCssRules(), e, pe, rl);
- }
+ if (mediaMatch(ir.getMedia())) {
+ try {
+ if (buri == null) {
+ buri = new URL(ir.getHref());
+ } else {
+ buri = new URL(buri, ir.getHref());
+ }
+ } catch (MalformedURLException ex) {
+ break;
+ }
+ CSSStyleSheet is = ir.getStyleSheet();
+ if (is != null) {
+ addMatchingRules(is.getCssRules(), e, pe, buri, rl);
+ }
+ }
break;
+
case CSSRule.MEDIA_RULE:
CSSMediaRule mr = (CSSMediaRule)rule;
if (mediaMatch(mr.getMedia())) {
- addMatchingRules(mr.getCssRules(), e, pe, rl);
+ addMatchingRules(mr.getCssRules(), e, pe, buri, rl);
}
break;
}
1.3 +22 -1 xml-batik/sources/org/apache/batik/css/CSSOMStyleRule.java
Index: CSSOMStyleRule.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/CSSOMStyleRule.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CSSOMStyleRule.java 2001/04/10 17:27:09 1.2
+++ CSSOMStyleRule.java 2001/10/18 12:30:22 1.3
@@ -9,6 +9,8 @@
package org.apache.batik.css;
import java.io.StringReader;
+import java.net.URL;
+
import org.apache.batik.css.value.ValueFactory;
import org.apache.batik.css.event.CSSStyleDeclarationChangeEvent;
import org.apache.batik.css.event.CSSStyleDeclarationChangeListener;
@@ -32,7 +34,7 @@
* This class implements the {@link org.w3c.dom.css.CSSStyleRule} interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: CSSOMStyleRule.java,v 1.2 2001/04/10 17:27:09 hillion Exp $
+ * @version $Id: CSSOMStyleRule.java,v 1.3 2001/10/18 12:30:22 hillion Exp $
*/
public class CSSOMStyleRule
extends AbstractCSSRule
@@ -67,6 +69,11 @@
* The Style rule change support.
*/
protected CSSStyleRuleChangeSupport styleRuleChangeSupport;
+
+ /**
+ * The base URI.
+ */
+ protected URL baseURI;
/**
* Creates a new rule set.
@@ -81,6 +88,20 @@
style = new CSSOMStyleDeclaration(this, p);
style.setValueFactoryMap(m);
style.addCSSStyleDeclarationChangeListener(this);
+ }
+
+ /**
+ * Sets the base URI.
+ */
+ public void setBaseURI(URL url) {
+ baseURI = url;
+ }
+
+ /**
+ * Returns the base URI.
+ */
+ public URL getBaseURI() {
+ return baseURI;
}
/**
1.4 +5 -5 xml-batik/sources/org/apache/batik/css/HiddenChildElement.java
Index: HiddenChildElement.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/HiddenChildElement.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HiddenChildElement.java 2001/10/17 14:47:26 1.3
+++ HiddenChildElement.java 2001/10/18 12:30:22 1.4
@@ -15,7 +15,7 @@
* of another element without being added to the DOM tree.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: HiddenChildElement.java,v 1.3 2001/10/17 14:47:26 hillion Exp $
+ * @version $Id: HiddenChildElement.java,v 1.4 2001/10/18 12:30:22 hillion Exp $
*/
public interface HiddenChildElement {
/**
@@ -29,12 +29,12 @@
void setParentElement(Element elt);
/**
- * Sets the cascaded style of this element.
+ * Gets the style of this element.
*/
- CSSOMReadOnlyStyleDeclaration getCascadedStyle();
+ CSSOMReadOnlyStyleDeclaration getStyleDeclaration();
/**
- * Sets the cascaded style of this element.
+ * Sets the style of this element.
*/
- void setCascadedStyle(CSSOMReadOnlyStyleDeclaration sd);
+ void setStyleDeclaration(CSSOMReadOnlyStyleDeclaration sd);
}
1.3 +2 -2
xml-batik/sources/org/apache/batik/css/HiddenChildElementSupport.java
Index: HiddenChildElementSupport.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/css/HiddenChildElementSupport.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HiddenChildElementSupport.java 2001/10/17 14:47:26 1.2
+++ HiddenChildElementSupport.java 2001/10/18 12:30:22 1.3
@@ -15,7 +15,7 @@
* This class provides utility methods for HiddenChildElement support.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: HiddenChildElementSupport.java,v 1.2 2001/10/17 14:47:26 hillion
Exp $
+ * @version $Id: HiddenChildElementSupport.java,v 1.3 2001/10/18 12:30:22 hillion
Exp $
*/
public class HiddenChildElementSupport {
/**
@@ -53,7 +53,7 @@
AbstractViewCSS srcv) {
CSSOMReadOnlyStyleDeclaration sd;
sd = (CSSOMReadOnlyStyleDeclaration)srcv.computeStyle(src, null);
- ((HiddenChildElement)e).setCascadedStyle(sd);
+ ((HiddenChildElement)e).setStyleDeclaration(sd);
sd.setContext(ev, e);
for (Node en = e.getFirstChild(), sn = src.getFirstChild();
1.1 xml-batik/sources/org/apache/batik/css/ExtendedLinkStyle.java
Index: ExtendedLinkStyle.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.css;
import org.w3c.dom.stylesheets.LinkStyle;
/**
* This interface is an extension of the standard LinkStyle interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
* @version $Id: ExtendedLinkStyle.java,v 1.1 2001/10/18 12:30:22 hillion Exp $
*/
public interface ExtendedLinkStyle extends LinkStyle {
/**
* Returns the URI of the referenced stylesheet.
*/
String getStyleSheetURI();
}
1.5 +2 -2
xml-batik/sources/org/apache/batik/dom/StyleSheetProcessingInstruction.java
Index: StyleSheetProcessingInstruction.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/dom/StyleSheetProcessingInstruction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StyleSheetProcessingInstruction.java 2001/10/11 18:37:33 1.4
+++ StyleSheetProcessingInstruction.java 2001/10/18 12:30:23 1.5
@@ -21,7 +21,7 @@
* instructions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: StyleSheetProcessingInstruction.java,v 1.4 2001/10/11 18:37:33
hillion Exp $
+ * @version $Id: StyleSheetProcessingInstruction.java,v 1.5 2001/10/18 12:30:23
hillion Exp $
*/
public class StyleSheetProcessingInstruction
extends AbstractProcessingInstruction
@@ -130,6 +130,6 @@
* Returns a new uninitialized instance of this object's class.
*/
protected Node newNode() {
- return new GenericAttr();
+ return new StyleSheetProcessingInstruction();
}
}
1.6 +9 -14 xml-batik/sources/org/apache/batik/dom/svg/AbstractElement.java
Index: AbstractElement.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/AbstractElement.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractElement.java 2001/10/17 14:47:26 1.5
+++ AbstractElement.java 2001/10/18 12:30:23 1.6
@@ -35,7 +35,7 @@
* an element interoperable with the SVG elements.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: AbstractElement.java,v 1.5 2001/10/17 14:47:26 hillion Exp $
+ * @version $Id: AbstractElement.java,v 1.6 2001/10/18 12:30:23 hillion Exp $
*/
public abstract class AbstractElement
extends org.apache.batik.dom.AbstractElement
@@ -57,7 +57,7 @@
/**
* The cascaded style, if any.
*/
- protected transient CSSOMReadOnlyStyleDeclaration cascadedStyle;
+ protected transient CSSOMReadOnlyStyleDeclaration styleDeclaration;
/**
* Creates a new Element object.
@@ -82,12 +82,7 @@
* Returns this element's base URI.
*/
public String getBaseURI() {
- try {
- return new java.net.URL(((SVGOMDocument)ownerDocument).getURLObject(),
- XMLBaseSupport.getXMLBase(this)).toString();
- } catch (java.net.MalformedURLException e) {
- throw new RuntimeException(e.getMessage());
- }
+ return XMLBaseSupport.getCascadedXMLBase(this);
}
// ElementWithID /////////////////////////////////////////////////
@@ -147,17 +142,17 @@
}
/**
- * Sets the cascaded style of this element.
+ * Gets the style of this element.
*/
- public CSSOMReadOnlyStyleDeclaration getCascadedStyle() {
- return cascadedStyle;
+ public CSSOMReadOnlyStyleDeclaration getStyleDeclaration() {
+ return styleDeclaration;
}
/**
- * Sets the cascaded style of this element.
+ * Sets the style of this element.
*/
- public void setCascadedStyle(CSSOMReadOnlyStyleDeclaration sd) {
- cascadedStyle = sd;
+ public void setStyleDeclaration(CSSOMReadOnlyStyleDeclaration sd) {
+ styleDeclaration = sd;
}
/**
1.41 +6 -7 xml-batik/sources/org/apache/batik/dom/svg/SVGOMDocument.java
Index: SVGOMDocument.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMDocument.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- SVGOMDocument.java 2001/10/11 18:37:33 1.40
+++ SVGOMDocument.java 2001/10/18 12:30:23 1.41
@@ -29,7 +29,6 @@
import org.apache.batik.dom.GenericEntityReference;
import org.apache.batik.dom.GenericProcessingInstruction;
import org.apache.batik.dom.GenericText;
-import org.apache.batik.dom.StyleSheetProcessingInstruction;
import org.apache.batik.dom.StyleSheetFactory;
import org.apache.batik.dom.util.OverrideStyleElement;
@@ -69,7 +68,7 @@
* This class implements {@link SVGDocument}.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: SVGOMDocument.java,v 1.40 2001/10/11 18:37:33 hillion Exp $
+ * @version $Id: SVGOMDocument.java,v 1.41 2001/10/18 12:30:23 hillion Exp $
*/
public class SVGOMDocument
extends AbstractDocument
@@ -292,14 +291,14 @@
/**
* <b>DOM</b>: Implements {@link
* Document#createProcessingInstruction(String,String)}.
- * @return a StyleSheetProcessingInstruction if target is
+ * @return a SVGStyleSheetProcessingInstruction if target is
* "xml-stylesheet" or a GenericProcessingInstruction otherwise.
*/
public ProcessingInstruction createProcessingInstruction(String target,
String data)
throws DOMException {
if ("xml-stylesheet".equals(target)) {
- return new StyleSheetProcessingInstruction
+ return new SVGStyleSheetProcessingInstruction
(data, this, (StyleSheetFactory)getImplementation());
}
return new GenericProcessingInstruction(target, data, this);
@@ -433,9 +432,9 @@
for (int i = 0; i < styleSheets.getLength(); i++) {
StyleSheet ss = (StyleSheet)styleSheets.item(i);
Node on = ss.getOwnerNode();
- if (on instanceof StyleSheetProcessingInstruction) {
- StyleSheetProcessingInstruction sspi;
- sspi = (StyleSheetProcessingInstruction)on;
+ if (on instanceof SVGStyleSheetProcessingInstruction) {
+ SVGStyleSheetProcessingInstruction sspi;
+ sspi = (SVGStyleSheetProcessingInstruction)on;
if ("yes".equals(sspi.getPseudoAttributes().get("alternate"))) {
ss.setDisabled(!title.equals(ss.getTitle()));
}
1.2 +10 -3 xml-batik/sources/org/apache/batik/dom/svg/XMLBaseSupport.java
Index: XMLBaseSupport.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/XMLBaseSupport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLBaseSupport.java 2001/10/12 07:33:09 1.1
+++ XMLBaseSupport.java 2001/10/18 12:30:23 1.2
@@ -23,7 +23,7 @@
* This class provides support for the xml:base attribute.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a>
- * @version $Id: XMLBaseSupport.java,v 1.1 2001/10/12 07:33:09 hillion Exp $
+ * @version $Id: XMLBaseSupport.java,v 1.2 2001/10/18 12:30:23 hillion Exp $
*/
public class XMLBaseSupport implements XMLConstants {
@@ -34,10 +34,17 @@
}
/**
+ * Returns the xml:base attribute value of the given element.
+ */
+ public static String getXMLBase(Element elt) {
+ return elt.getAttributeNS(XML_NAMESPACE_URI, "base");
+ }
+
+ /**
* Returns the xml:base attribute value of the given element
* Resolving any dependency on parent bases if needed.
*/
- public static String getXMLBase(Element elt) {
+ public static String getCascadedXMLBase(Element elt) {
String base = null;
Node n = elt;
while (true) {
@@ -51,7 +58,7 @@
// new Exception("N: " + n).printStackTrace();
if (n== null) break;
if (n.getNodeType() == Node.ELEMENT_NODE) {
- base = getXMLBase((Element)n);
+ base = getCascadedXMLBase((Element)n);
break;
}
}
1.1
xml-batik/sources/org/apache/batik/dom/svg/SVGStyleSheetProcessingInstruction.java
Index: SVGStyleSheetProcessingInstruction.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.dom.svg;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.batik.css.ExtendedLinkStyle;
import org.apache.batik.dom.AbstractDocument;
import org.apache.batik.dom.StyleSheetFactory;
import org.apache.batik.dom.StyleSheetProcessingInstruction;
import org.w3c.dom.Node;
/**
* This class provides an implementation of the 'xml-stylesheet' processing
* instructions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
* @version $Id: SVGStyleSheetProcessingInstruction.java,v 1.1 2001/10/18 12:30:23
hillion Exp $
*/
public class SVGStyleSheetProcessingInstruction
extends StyleSheetProcessingInstruction
implements ExtendedLinkStyle {
/**
* Creates a new ProcessingInstruction object.
*/
protected SVGStyleSheetProcessingInstruction() {
}
/**
* Creates a new ProcessingInstruction object.
*/
public SVGStyleSheetProcessingInstruction(String data,
AbstractDocument owner,
StyleSheetFactory f) {
super(data, owner, f);
}
/**
* Returns the URI of the referenced stylesheet.
*/
public String getStyleSheetURI() {
SVGOMDocument svgDoc;
svgDoc = (SVGOMDocument)getOwnerDocument();
URL url = svgDoc.getURLObject();
String href = (String)getPseudoAttributes().get("href");
if (url != null) {
try {
return new URL(url, href).toString();
} catch (MalformedURLException e) {
}
}
return href;
}
/**
* Returns a new uninitialized instance of this object's class.
*/
protected Node newNode() {
return new SVGStyleSheetProcessingInstruction();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]