1 /********************************************** 2 * Copyright (C) 2010 Lukas Laag 3 * This file is part of lib-gwt-svg. 4 * 5 * libgwtsvg is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * libgwtsvg is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with libgwtsvg. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 /* 19 * Copyright (c) 2004 World Wide Web Consortium, 20 * 21 * (Massachusetts Institute of Technology, European Research Consortium for 22 * Informatics and Mathematics, Keio University). All Rights Reserved. This 23 * work is distributed under the W3C(r) Software License [1] in the hope that 24 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 25 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 26 * 27 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 28 */ 29 package org.vectomatic.dom.svg.impl; 30 31 import org.w3c.dom.DOMException; 32 33 import com.google.gwt.core.client.JavaScriptException; 34 import com.google.gwt.dom.client.Element; 35 import com.google.gwt.dom.client.Node; 36 37 /** 38 * Overlay class for DOM Attr 39 * @author laaglu 40 */ 41 public class Attr extends Node { 42 /** 43 * Constructor 44 */ 45 protected Attr() { 46 } 47 /** 48 * Returns the name of this attribute. If <code>OMNode.localName</code> is 49 * different from <code>null</code>, this attribute is a qualified name. 50 * @return the attribute name 51 */ 52 public final native String getName() /*-{ 53 return this.name; 54 }-*/; 55 56 /** 57 * On retrieval, the value of the attribute is returned as a string. 58 * Character and general entity references are replaced with their 59 * values. See also the method <code>getAttribute</code> on the 60 * <code>Element</code> interface. 61 * <br>On setting, this creates a <code>Text</code> node with the unparsed 62 * contents of the string, i.e. any characters that an XML processor 63 * would recognize as markup are instead treated as literal text. See 64 * also the method <code>Element.setAttribute()</code>. 65 * <br> Some specialized implementations, such as some [<a href='http://www.w3.org/TR/2003/REC-SVG11-20030114/'>SVG 1.1</a>] 66 * implementations, may do normalization automatically, even after 67 * mutation; in such case, the value on retrieval may differ from the 68 * value on setting. 69 * @return the attribute value 70 */ 71 public final native String getValue() /*-{ 72 return this.value; 73 }-*/; 74 75 /** 76 * On retrieval, the value of the attribute is returned as a string. 77 * Character and general entity references are replaced with their 78 * values. See also the method <code>getAttribute</code> on the 79 * <code>Element</code> interface. 80 * <br>On setting, this creates a <code>Text</code> node with the unparsed 81 * contents of the string, i.e. any characters that an XML processor 82 * would recognize as markup are instead treated as literal text. See 83 * also the method <code>Element.setAttribute()</code>. 84 * <br> Some specialized implementations, such as some [<a href='http://www.w3.org/TR/2003/REC-SVG11-20030114/'>SVG 1.1</a>] 85 * implementations, may do normalization automatically, even after 86 * mutation; in such case, the value on retrieval may differ from the 87 * value on setting. 88 * @param value the attribute value 89 * @exception DOMException 90 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 91 */ 92 public final native void setValue(String value) throws JavaScriptException /*-{ 93 this.value = value; 94 }-*/; 95 96 /** 97 * Returns whether this attribute is known to be of type ID (i.e. to 98 * contain an identifier for its owner element) or not. When it is and 99 * its value is unique, the <code>ownerElement</code> of this attribute 100 * can be retrieved using the method <code>Document.getElementById</code> 101 * . The implementation could use several ways to determine if an 102 * attribute node is known to contain an identifier: 103 * <ul> 104 * <li> If validation 105 * occurred using an XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>] 106 * while loading the document or while invoking 107 * <code>Document.normalizeDocument()</code>, the post-schema-validation 108 * infoset contributions (PSVI contributions) values are used to 109 * determine if this attribute is a schema-determined ID attribute using 110 * the <a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/#term-sdi'> 111 * schema-determined ID</a> definition in [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>] 112 * . 113 * </li> 114 * <li> If validation occurred using a DTD while loading the document or 115 * while invoking <code>Document.normalizeDocument()</code>, the infoset <b>[type definition]</b> value is used to determine if this attribute is a DTD-determined ID 116 * attribute using the <a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/#term-ddi'> 117 * DTD-determined ID</a> definition in [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>] 118 * . 119 * </li> 120 * <li> from the use of the methods <code>Element.setIdAttribute()</code>, 121 * <code>Element.setIdAttributeNS()</code>, or 122 * <code>Element.setIdAttributeNode()</code>, i.e. it is an 123 * user-determined ID attribute; 124 * <p ><b>Note:</b> XPointer framework (see section 3.2 in [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>] 125 * ) consider the DOM user-determined ID attribute as being part of the 126 * XPointer externally-determined ID definition. 127 * </li> 128 * <li> using mechanisms that 129 * are outside the scope of this specification, it is then an 130 * externally-determined ID attribute. This includes using schema 131 * languages different from XML schema and DTD. 132 * </li> 133 * </ul> 134 * <br> If validation occurred while invoking 135 * <code>Document.normalizeDocument()</code>, all user-determined ID 136 * attributes are reset and all attribute nodes ID information are then 137 * reevaluated in accordance to the schema used. As a consequence, if 138 * the <code>Attr.schemaTypeInfo</code> attribute contains an ID type, 139 * <code>isId</code> will always return true. 140 * @since DOM Level 3 141 */ 142 public final native boolean isId() /*-{ 143 return this.isId; 144 }-*/; 145 146 /** 147 * The <code>Element</code> node this attribute is attached to or 148 * <code>null</code> if this attribute is not in use. 149 */ 150 public final native Element getOwnerElement() /*-{ 151 return this.ownerElement; 152 }-*/; 153 154 }