Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > e4159201f91ca7f48047851cb47ad15b > files > 2

xt-dash1-19991105-3.mga3.src.rpm

--- com/jclark/xsl/dom/NodeBase.java	Tue Nov  2 16:38:48 1999
+++ com/jclark/xsl/dom/NodeBase.java	Mon Nov  8 02:53:54 1999
@@ -3,8 +3,8 @@
 import com.jclark.xsl.om.*;
 import java.net.URL;
 
-abstract class NodeBase implements Node {
-  final org.w3c.dom.Node domNode;
+public abstract class NodeBase implements Node {
+  public final org.w3c.dom.Node domNode;
   int level;
   private int childIndex;
   ContainerNode parent;
--- com/jclark/xsl/dom/RootNode.java	Fri Nov  5 05:51:33 1999
+++ com/jclark/xsl/dom/RootNode.java	Wed Apr 26 02:10:48 2000
@@ -5,7 +5,7 @@
 import java.net.URL;
 import java.net.MalformedURLException;
 
-class RootNode extends ContainerNode {
+public class RootNode extends ContainerNode {
   private org.w3c.dom.Document document;   // maybe null
   org.w3c.dom.Document ownerDocument; // never null
   private org.w3c.dom.NamedNodeMap entities;
@@ -17,7 +17,7 @@
   boolean includeComments;
   boolean includeProcessingInstructions;
 
-  RootNode(org.w3c.dom.Node node,
+  public RootNode(org.w3c.dom.Node node,
 	   DOMExtensions extend,
 	   LoadContext loadContext,
 	   NameTable nameTable,
@@ -89,17 +89,125 @@
     return createElement(node);
   }
 
-  private ContainerNode createElement(org.w3c.dom.Node node) {
+  private ContainerNode createContainer(org.w3c.dom.Node node) {
     org.w3c.dom.Node domParent = node.getParentNode();
     while (domParent.getNodeType() == org.w3c.dom.Node.ENTITY_REFERENCE_NODE)
       domParent = domParent.getParentNode();
+
+    if (domParent.equals(domNode))
+      return this;
+
+    return createElement(domParent);
+  }
+
+  public ContainerNode createElement(org.w3c.dom.Node node) {
+    ContainerNode container = createContainer(node);
+
+    // OPT It would be better to compute the child index lazily.
+    return new ElementNode(node, container, SiblingNodeIterator.computeChildIndex(container, node));
+  }
+
+  public Node createPI(org.w3c.dom.Node node) {
+    ContainerNode container = createContainer(node);
+
+    // OPT It would be better to compute the child index lazily.
+    return new ProcessingInstructionNode(node, container, SiblingNodeIterator.computeChildIndex(container, node));
+  }
+
+  public Node createComment(org.w3c.dom.Node node) {
+    ContainerNode container = createContainer(node);
+
+    // OPT It would be better to compute the child index lazily.
+    return new CommentNode(node, container, SiblingNodeIterator.computeChildIndex(container, node));
+  }
+
+  public Node createText(org.w3c.dom.Node node) {
+    Node text_node = null;
+
+    ContainerNode container = createContainer(node);
+
+    // OPT It would be better to compute the child index lazily.
+    int idx = SiblingNodeIterator.computeChildIndex(container, node);
+
+    org.w3c.dom.Node firstSibling = container.domNode.getFirstChild();
+    SafeNodeIterator iter = new SiblingNodeIterator(container, 0, firstSibling);
+
+    for (int i = 0; i < idx; i++)
+      text_node = iter.next();
+
+    return text_node;
+
+//    return new TextNode(node, container, SiblingNodeIterator.computeChildIndex(container, node));
+  }
+
+  public Node createAttribute(org.w3c.dom.Node node)
+  {
+    java.lang.reflect.Method method = null;
+
+    // first try using DOM Level 2 method (getOwnerElement)
+    try
+    {
+      Class cls = Class.forName("org.w3c.dom.Attr");
+      Class[] paramCls = new Class[0];
+
+      method = cls.getDeclaredMethod("getOwnerElement", paramCls);
+    }
+    catch (java.lang.ClassNotFoundException e)
+    {
+      return null;
+    }
+    catch (java.lang.NoSuchMethodException e)
+    {
+      method = null;
+    }
+
+    if (method == null)
+	return null;
+
+    Object[] params = new Object[0];
+
+    org.w3c.dom.Node domParent;
+
+    try
+    {
+        domParent = (org.w3c.dom.Node)method.invoke(node, params);
+    }
+    catch (java.lang.reflect.InvocationTargetException e)
+    {
+      return null;
+    }
+    catch (java.lang.IllegalAccessException e)
+    {
+      return null;
+    }
+
+    while (domParent.getNodeType() == org.w3c.dom.Node.ENTITY_REFERENCE_NODE)
+      domParent = domParent.getParentNode();
     ContainerNode tem;
     if (domParent.equals(domNode))
       tem = this;
     else
       tem = createElement(domParent);
+
+    Name attrName = root.nameTable.createName(node.getNodeName());
+
+    org.w3c.dom.NamedNodeMap domAttributes = domParent.getAttributes();
+    int len = domAttributes.getLength();
+    int i;
+    for (i = 0; i < len; i++)
+    {
+	org.w3c.dom.Node domAttribute = domAttributes.item(i);
+	if (domAttribute.getNodeName().equals(node.getNodeName()))
+	    break;
+    }
+
     // OPT It would be better to compute the child index lazily.
-    return new ElementNode(node, tem, SiblingNodeIterator.computeChildIndex(tem, node));
+    if (i < len)
+	return new AttributeNode(attrName, node, tem,
+				 // attributes occur before children
+				 i - len - 1);
+
+    return null;
   }
 
   public String getGeneratedId() {
--- com/jclark/xsl/dom/SiblingNodeIterator.java	Fri Oct 29 13:29:17 1999
+++ com/jclark/xsl/dom/SiblingNodeIterator.java	Wed Apr 26 01:53:12 2000
@@ -2,7 +2,7 @@
 
 import com.jclark.xsl.om.*;
 
-class SiblingNodeIterator implements SafeNodeIterator {
+public class SiblingNodeIterator implements SafeNodeIterator {
   ContainerNode parent;
   int childIndex;
   NodeBase node;
@@ -49,7 +49,7 @@
     }
   }
 
-  static int computeChildIndex(ContainerNode parent, org.w3c.dom.Node domNode) {
+  public static int computeChildIndex(ContainerNode parent, org.w3c.dom.Node domNode) {
     int preserveSpace = -1;
     boolean ignoreText = false;
     int childIndex = 0;
--- com/jclark/xsl/expr/ArrayNodeIterator.java	Wed Apr 14 12:05:24 1999
+++ com/jclark/xsl/expr/ArrayNodeIterator.java	Tue Dec 14 07:59:24 1999
@@ -2,12 +2,12 @@
 
 import com.jclark.xsl.om.*;
 
-class ArrayNodeIterator implements NodeIterator {
+public class ArrayNodeIterator implements NodeIterator {
   private int i;
   private int len;
   private Node[] nodes;
 
-  ArrayNodeIterator(Node[] nodes, int start, int end) {
+  public ArrayNodeIterator(Node[] nodes, int start, int end) {
     this.nodes = nodes;
     this.len = end;
     this.i = start;
--- com/jclark/xsl/expr/ExprParser.java	Fri Nov  5 08:01:22 1999
+++ com/jclark/xsl/expr/ExprParser.java	Wed Aug  2 04:25:00 2000
@@ -390,7 +390,8 @@
       if (isAttributeAxis)
 	nodeTest = new AttributeTest(expandName());
       else
-	nodeTest = new ElementTest(expandName());
+//	nodeTest = new ElementTest(expandName());
+	nodeTest = new ElementTest(expandElementTypeName());
       break;
     case TOK_STAR:
       nodeTest = isAttributeAxis ? null : new NodeTypeTest(Node.ELEMENT);
@@ -547,6 +548,18 @@
     try {
       if (prefixMap != null)
 	return prefixMap.expandAttributeName(currentTokenValue, null);
+      else
+	return null;
+    }
+    catch (XSLException e) {
+      throw new ParseException("undefined prefix");
+    }
+  }
+
+  private Name expandElementTypeName() throws ParseException {
+    try {
+      if (prefixMap != null)
+	return prefixMap.expandElementTypeName(currentTokenValue, null);
       else
 	return null;
     }
--- com/jclark/xsl/expr/NodeSetVariant.java	Tue Nov  2 19:54:34 1999
+++ com/jclark/xsl/expr/NodeSetVariant.java	Tue Dec 14 06:38:32 1999
@@ -2,10 +2,10 @@
 
 import com.jclark.xsl.om.*;
 
-class NodeSetVariant extends VariantBase {
+public class NodeSetVariant extends VariantBase {
   private final NodeIterator iter;
 
-  NodeSetVariant(NodeIterator iter) {
+  public NodeSetVariant(NodeIterator iter) {
     this.iter = iter;
   }