Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@
</java>

<!-- Now do the XHTML gwt bugfix, replacing the 2 .write methods -->
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="m.write(gb+b+hb)"
value="var script=document.createElement(&quot;script&quot;);script.setAttribute(&quot;id&quot;, b);m.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)"/>
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="n.write(hb+b+ib)"
value="var script=n.createElement(&quot;script&quot;);script.setAttribute(&quot;id&quot;, b);n.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)"/>
<!--
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token='m.write($b)' value='var script=document.createElement("script");script.setAttribute("defer", "defer");script.innerHTML="Saxonce.onInjectionDone(&apos;Saxonce&apos;)";m.getElementsByTagName("head")[0].appendChild(script)'/>
-->
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="m.write($b)"
value="try{var script=document.createElement(&quot;script&quot;);script.setAttribute(&quot;defer&quot;, &quot;defer&quot;);script.innerHTML=&quot;Saxonce.onInjectionDone(&apos;Saxonce&apos;)&quot;;m.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)}catch(e9){m.write($b)}"/>
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="n.write(Zb)"
value="try{var script=n.createElement(&quot;script&quot;);script.setAttribute(&quot;defer&quot;, &quot;defer&quot;);script.innerHTML=&quot;Saxonce.onInjectionDone(&apos;Saxonce&apos;)&quot;;n.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)}catch(e9){n.write(Zb);}"/>

<!-- Pretty print version -->
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="$doc_0.write(&apos;&lt;script id=&quot;&apos; + markerId + &apos;&quot;&gt;&lt;\/script&gt;&apos;)"
value="var script=$doc_0.createElement(&quot;script&quot;);script.setAttribute(&quot;id&quot;, markerId);$doc_0.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)"/>
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="$doc_0.write(&apos;&lt;script defer=&quot;defer&quot;&gt;Saxonce.onInjectionDone(\&apos;Saxonce\&apos;)&lt;\/script&gt;&apos;)"
value="try{var script=$doc_0.createElement(&quot;script&quot;);script.setAttribute(&quot;defer&quot;, &quot;defer&quot;);script.innerHTML=&quot;Saxonce.onInjectionDone(&apos;Saxonce&apos;)&quot;;$doc_0.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)}catch(e9){$doc_0.write(&apos;&lt;script defer=&quot;defer&quot;&gt;Saxonce.onInjectionDone(\&apos;Saxonce\&apos;)&lt;\/script&gt;&apos;);}"/>

<move file="${temp_path}/Saxonce" tofile="${deploy_path}/SaxonceDebug"/>
<delete>
Expand Down Expand Up @@ -106,13 +112,19 @@
value="&quot;gwt.logging.enabled&quot; value=&quot;TRUE&quot;"/>

<!-- Now do the XHTML gwt bugfix, replacing the 2 .write methods -->
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="m.write(gb+b+hb)"
value="var script=document.createElement(&quot;script&quot;);script.setAttribute(&quot;id&quot;, b);m.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)"/>
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="n.write(hb+b+ib)"
value="var script=n.createElement(&quot;script&quot;);script.setAttribute(&quot;id&quot;, b);n.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)"/>
<!--
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token='m.write($b)' value='var script=document.createElement("script");script.setAttribute("defer", "defer");script.innerHTML="Saxonce.onInjectionDone(&apos;Saxonce&apos;)";m.getElementsByTagName("head")[0].appendChild(script)'/>
-->
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="m.write($b)"
value="try{var script=document.createElement(&quot;script&quot;);script.setAttribute(&quot;defer&quot;, &quot;defer&quot;);script.innerHTML=&quot;Saxonce.onInjectionDone(&apos;Saxonce&apos;)&quot;;m.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)}catch(e9){m.write($b)}"/>
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="n.write(Zb)"
value="try{var script=n.createElement(&quot;script&quot;);script.setAttribute(&quot;defer&quot;, &quot;defer&quot;);script.innerHTML=&quot;Saxonce.onInjectionDone(&apos;Saxonce&apos;)&quot;;n.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)}catch(e9){n.write(Zb);}"/>

<!-- Pretty print version -->
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="$doc_0.write(&apos;&lt;script id=&quot;&apos; + markerId + &apos;&quot;&gt;&lt;\/script&gt;&apos;)"
value="var script=$doc_0.createElement(&quot;script&quot;);script.setAttribute(&quot;id&quot;, markerId);$doc_0.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)"/>
<replace file="${temp_path}/Saxonce/Saxonce.nocache.js" token="$doc_0.write(&apos;&lt;script defer=&quot;defer&quot;&gt;Saxonce.onInjectionDone(\&apos;Saxonce\&apos;)&lt;\/script&gt;&apos;)"
value="try{var script=$doc_0.createElement(&quot;script&quot;);script.setAttribute(&quot;defer&quot;, &quot;defer&quot;);script.innerHTML=&quot;Saxonce.onInjectionDone(&apos;Saxonce&apos;)&quot;;$doc_0.getElementsByTagName(&quot;head&quot;)[0].appendChild(script)}catch(e9){$doc_0.write(&apos;&lt;script defer=&quot;defer&quot;&gt;Saxonce.onInjectionDone(\&apos;Saxonce\&apos;)&lt;\/script&gt;&apos;);}"/>

<move file="${temp_path}/Saxonce" tofile="${deploy_path}/Saxonce"/>

Expand Down
85 changes: 46 additions & 39 deletions src/client/net/sf/saxon/ce/dom/HTMLWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ private native Element createElementNS(Document doc,
}
return null;
}-*/;

private native Node createProcessingInstruction(Document doc,
final String target,
final String data) /*-{
return doc.createProcessingInstruction(target, data);
}-*/;

private native Node createComment(Document doc,
final String data) /*-{
return doc.createComment(data);
}-*/;

private static native boolean attNSSupported(Document doc) /*-{
return (typeof doc.createNode == "function" || typeof doc.createAttributeNS == "function");
}-*/;

public static void setAttribute(Document doc,
Element element,
String name,
Expand All @@ -93,7 +93,7 @@ public static void setAttribute(Document doc,
setAttributeProps(element, name, value);
}
}

public static String tableAttributeFix(String name, WriteMode wMode){
if (wMode != WriteMode.XML && Configuration.getIeVersion() > 0 && name.length() > 5){
if (name.equals("rowspan")){
Expand All @@ -108,16 +108,16 @@ public static String tableAttributeFix(String name, WriteMode wMode){
}
return name;
}


// This throws an exception in IE7 that must be handled, in IE, you can only create a namespace-qualified
// attribute using the createNode method of the DOMDocument.
/**
* Creates an attribute with a namespace.
* This throws an exception in IE7 that (it seems) must be handled by the caller,
* in IE, you can only create a namespace-qualified attribute using the createNode method
* of the DOMDocument.
*
*
*/
public static native void setAttributeJs(Document doc,
final Node element,
Expand All @@ -131,10 +131,10 @@ public static native void setAttributeJs(Document doc,
} else {
att = doc.createAttributeNS(URI, name);
att.nodeValue = value;
}
element.setAttributeNode(att);
}
element.setAttributeNode(att);
}-*/;


/**
* Set the pipelineConfiguration
Expand Down Expand Up @@ -206,20 +206,20 @@ public void startElement(int nameCode, int properties) throws XPathException {
String localName = namePool.getLocalName(nameCode);
String prefix = namePool.getPrefix(nameCode);
String uri = namePool.getURI(nameCode);

// TODO: For XML Writer it should write prefixes in a
// way compliant with the XSLT2.0 specification - using xsl:output attributes
Element element = null;
if (uri != null && !uri.isEmpty()) {
if(mode == WriteMode.XML && !prefix.equals("")) {
element = createElementNS(document, uri, prefix+":"+localName);

} else {
// no svg specific prefix now used, for compliance with HTML5
element = createElementNS(document, uri, localName);
}
}

// if there's no namespace - or no namespace support
if (element == null) {
element = document.createElement(localName);
Expand Down Expand Up @@ -251,7 +251,7 @@ public void startElement(int nameCode, int properties) throws XPathException {
if(uri.equals(NamespaceConstant.IXSL)) {
XPathException xpe = new XPathException("Error on adding IXSL element to the DOM, the IXSL namespace should be added to the 'extension-element-prefixes' list.");
throw(xpe);
} else {
} else {
throw(new XPathException(err.getMessage()));
}
} catch(Exception exc) {
Expand All @@ -263,9 +263,16 @@ public void startElement(int nameCode, int properties) throws XPathException {
level++;
}

public final static native void setAttributeNS(Element elem, String nameSpace, String name, String value) /*-{
elem.setAttributeNS(nameSpace, name, value);
}-*/;

private static void addNamespace(Element element, String prefix, String uri) {
String attName = (prefix.isEmpty() ? "xmlns" : "xmlns:" + prefix);
element.setAttribute(attName, uri);
if (prefix.isEmpty()) {
element.setAttribute("xmlns", uri);
} else {
setAttributeNS(element, "http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, uri);
}
}

public void namespace (NamespaceBinding nsBinding, int properties) throws XPathException {
Expand All @@ -277,7 +284,7 @@ public void namespace (NamespaceBinding nsBinding, int properties) throws XPathE
addNamespace(element, prefix, uri);
}
}

}

public void attribute(int nameCode, CharSequence value)
Expand Down Expand Up @@ -306,7 +313,7 @@ public void attribute(int nameCode, CharSequence value)
setAttributeProps(element, localName, val);
}
}

/**
* Method for backward compatibility with IE8 and previous where
* properties and attributes were handled separately
Expand All @@ -327,19 +334,19 @@ public static void setAttributePropsOriginal(Element element, String localName,
setTitle(element, val);
// } else if (localName.equals("align") || localName.equals("width")) {
// setElementProperty(element, localName, val);
} else {
} else {
setElementProperty(element, localName, val);
}
} else if (localName.length() == 2 && localName.equals("id")) {
setId(element, val);
// } else if (localName.length() == 7 && localName.equals("colSpan") || localName.equals("rowSpan") ) {
// setElementProperty(element, localName, val);
} else {
} else {
setElementProperty(element, localName, val);
}
}
}

/**
* following setElementProperty method call doesn't work consistently
* because in IE some element are initially undefined?
Expand All @@ -362,35 +369,35 @@ public static void setAttributeProps(Element element, String localName, String v
}
}
}

private static native boolean hasStyle(Element element) /*-{
return (typeof element.style !== "undefined");
}-*/;

private static native boolean setClass(Element element, String value) /*-{
if (typeof element.className !== "undefined") {
element.className = value;
}
}-*/;

private static native boolean setId(Element element, String value) /*-{
if (typeof element.id !== "undefined") {
element.id = value;
}
}-*/;

private static native boolean setTitle(Element element, String value) /*-{
if (typeof element.title !== "undefined") {
element.title = value;
}
}-*/;

private static native void setElementProperty(Element element, String name, String value) /*-{
if (typeof element[name] !== "undefined") {
element[name] = value;
}
}-*/;

/**
* Parse the value of the style attribute and use it to set individual properties of the style object
* @param element the element whose style properties are to be updated
Expand All @@ -417,7 +424,7 @@ public static void setStyleProperties(Element element, String styleAttribute) {
setStyleProperties(element, styleAttribute.substring(semi+1));
}
}

public static String getCamelCaseName(String prop) {
while (prop.contains("-")) {
int h = prop.indexOf('-');
Expand Down Expand Up @@ -481,7 +488,7 @@ public void processingInstruction(String target, CharSequence data)
if (mode == WriteMode.XML) {
JavaScriptObject pi = createProcessingInstruction(document, target, data.toString());
addNode(pi, "processing-instruction");
}
}
}

/**
Expand All @@ -496,7 +503,7 @@ public void comment(CharSequence chars) throws XPathException
addNode(comment, "comment");
}
}

public void addNode(JavaScriptObject newNode, String nodeType) throws XPathException {
try {
if (nextSibling != null && level == 0) {
Expand All @@ -509,11 +516,11 @@ public void addNode(JavaScriptObject newNode, String nodeType) throws XPathExcep
throw(new XPathException("DOM error " + desc + " " + nodeType + " node to node with name: " + currentNode.getNodeName()));
}
}

public final native JavaScriptObject appendChild(JavaScriptObject parent, JavaScriptObject newChild) /*-{
return parent.appendChild(newChild);
}-*/;

public final native JavaScriptObject insertBefore(JavaScriptObject targetNode, JavaScriptObject newNode) /*-{
return targetNode.insertBefore(newNode);
}-*/;
Expand All @@ -522,13 +529,13 @@ public final native JavaScriptObject insertBefore(JavaScriptObject targetNode, J
* Set the attachment point for the new subtree
* @param node the node to which the new subtree will be attached
*/

public enum WriteMode {
NONE, XML, HTML
}





private WriteMode mode = WriteMode.NONE;

public void setNode (Node node) {
Expand All @@ -539,15 +546,15 @@ public void setNode (Node node) {
if (node.getNodeType() == Node.DOCUMENT_NODE) {
document = (Document)node;
} else {
document = currentNode.getOwnerDocument();
document = currentNode.getOwnerDocument();
}
if (mode == WriteMode.NONE) {
Controller.APIcommand cmd = pipe.getController().getApiCommand();
mode = (cmd == APIcommand.TRANSFORM_TO_DOCUMENT || cmd == APIcommand.TRANSFORM_TO_FRAGMENT)?
WriteMode.XML : WriteMode.HTML;
}
}

public Node getNode() {
// though this is changed by startElement it's reset by endElement and therefore,
// when called after close, should always return the initial container node
Expand All @@ -568,6 +575,6 @@ public void setNextSibling(Node nextSibling) {

}

// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.