/[classpath]/classpath/gnu/xml/transform/Stylesheet.java
ViewVC logotype

Diff of /classpath/gnu/xml/transform/Stylesheet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gnu_andrew, Sat Feb 12 14:26:02 2005 UTC revision 1.3 by dog, Thu Jun 30 22:09:07 2005 UTC
# Line 248  class Stylesheet Line 248  class Stylesheet
248      Test anyNode = new NodeTypeTest((short) 0);      Test anyNode = new NodeTypeTest((short) 0);
249      List tests = Collections.singletonList(anyNode);      List tests = Collections.singletonList(anyNode);
250      builtInNodeTemplate =      builtInNodeTemplate =
251        new ApplyTemplatesNode(null, null,        new ApplyTemplatesNode(new Selector(Selector.CHILD, tests),
                              new Selector(Selector.CHILD, tests),  
252                               null, null, null, true);                               null, null, null, true);
253      builtInTextTemplate =      builtInTextTemplate =
254        new ValueOfNode(null, null,        new ValueOfNode(new Selector(Selector.SELF, tests),
                       new Selector(Selector.SELF, tests),  
255                        false);                        false);
256            
257      parse(doc.getDocumentElement(), true);      parse(doc.getDocumentElement(), true);
# Line 495  class Stylesheet Line 493  class Stylesheet
493      QName mode = (mm == null) ? null : getQName(mm);      QName mode = (mm == null) ? null : getQName(mm);
494      double priority = (p == null) ? Template.DEFAULT_PRIORITY :      double priority = (p == null) ? Template.DEFAULT_PRIORITY :
495        Double.parseDouble(p);        Double.parseDouble(p);
496      return new Template(this, name, match, parse(node.getFirstChild()),      Node children = node.getFirstChild();
497        return new Template(this, name, match, parse(children),
498                          precedence, priority, mode);                          precedence, priority, mode);
499    }    }
500    
# Line 654  class Stylesheet Line 653  class Stylesheet
653    void parse(Node node, boolean root)    void parse(Node node, boolean root)
654      throws TransformerConfigurationException      throws TransformerConfigurationException
655    {    {
656      if (node == null)      while (node != null)
657        {        {
658          return;          current = node;
659            doParse(node, root);
660            node = node.getNextSibling();
661        }        }
662      current = node;    }
663    
664      void doParse(Node node, boolean root)
665        throws TransformerConfigurationException
666      {
667      try      try
668        {        {
669          String namespaceUri = node.getNamespaceURI();          String namespaceUri = node.getNamespaceURI();
# Line 689  class Stylesheet Line 694  class Stylesheet
694                        }                        }
695                    }                    }
696                  parse(node.getFirstChild(), false);                  parse(node.getFirstChild(), false);
                 return;  
697                }                }
698              else if ("template".equals(name))              else if ("template".equals(name))
699                {                {
700                  templates.addFirst(parseTemplate(node, attrs));                  templates.add(parseTemplate(node, attrs));
701                }                }
702              else if ("param".equals(name) ||              else if ("param".equals(name) ||
703                       "variable".equals(name))                       "variable".equals(name))
# Line 702  class Stylesheet Line 706  class Stylesheet
706                  TemplateNode content = parse(node.getFirstChild());                  TemplateNode content = parse(node.getFirstChild());
707                  String paramName = getRequiredAttribute(attrs, "name", node);                  String paramName = getRequiredAttribute(attrs, "name", node);
708                  String select = getAttribute(attrs, "select");                  String select = getAttribute(attrs, "select");
709                    ParameterNode param;
710                  if (select != null && select.length() > 0)                  if (select != null && select.length() > 0)
711                    {                    {
712                      if (content != null)                      if (content != null)
# Line 712  class Stylesheet Line 717  class Stylesheet
717                          throw new TransformerConfigurationException(msg, l);                          throw new TransformerConfigurationException(msg, l);
718                        }                        }
719                      Expr expr = (Expr) xpath.compile(select);                      Expr expr = (Expr) xpath.compile(select);
720                      variables.add(new ParameterNode(null, null,                      param = new ParameterNode(paramName, expr, global);
                                                     paramName,  
                                                     expr, global));  
721                    }                    }
722                  else                  else
723                    {                    {
724                      variables.add(new ParameterNode(content, null,                      param = new ParameterNode(paramName, null, global);
725                                                      paramName,                      param.children = content;
                                                     null, global));  
726                    }                    }
727                    variables.add(param);
728                  bindings.set(paramName, content, global);                  bindings.set(paramName, content, global);
729                }                }
730              else if ("include".equals(name) || "import".equals(name))              else if ("include".equals(name) || "import".equals(name))
# Line 784  class Stylesheet Line 787  class Stylesheet
787                {                {
788                  parseAttributeSet(node, attrs);                  parseAttributeSet(node, attrs);
789                }                }
             parse(node.getNextSibling(), false);  
790            }            }
791          else if (root)          else if (root)
792            {            {
# Line 810  class Stylesheet Line 812  class Stylesheet
812          else          else
813            {            {
814              // Skip unknown elements, text, comments, etc              // Skip unknown elements, text, comments, etc
             parse(node.getNextSibling(), false);  
815            }            }
816        }        }
817      catch (TransformerException e)      catch (TransformerException e)
# Line 949  class Stylesheet Line 950  class Stylesheet
950            {            {
951              // Expression text              // Expression text
952              Expr select = (Expr) xpath.compile(token);              Expr select = (Expr) xpath.compile(token);
953              ret = new ValueOfNode(null, ret, select, false);              TemplateNode ret2 = new ValueOfNode(select, false);
954                ret2.next = ret;
955                ret = ret2;
956            }            }
957          else          else
958            {            {
959              // Verbatim text              // Verbatim text
960              ret = new LiteralNode(null, ret, doc.createTextNode(token));              TemplateNode ret2 = new LiteralNode(doc.createTextNode(token));
961                ret2.next = ret;
962                ret = ret2;
963            }            }
964        }        }
965      return ret;      return ret;
# Line 1095  class Stylesheet Line 1100  class Stylesheet
1100    /**    /**
1101     * apply-templates     * apply-templates
1102     */     */
1103    final TemplateNode parseApplyTemplates(Node node, Node children, Node next)    final TemplateNode parseApplyTemplates(Node node)
1104      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1105    {    {
1106      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
# Line 1106  class Stylesheet Line 1111  class Stylesheet
1111        {        {
1112          s = "child::node()";          s = "child::node()";
1113        }        }
1114        Node children = node.getFirstChild();
1115      List sortKeys = parseSortKeys(children);      List sortKeys = parseSortKeys(children);
1116      List withParams = parseWithParams(children);      List withParams = parseWithParams(children);
1117      Expr select = (Expr) xpath.compile(s);      Expr select = (Expr) xpath.compile(s);
1118      return new ApplyTemplatesNode(null, parse(next),      return new ApplyTemplatesNode(select, mode,
                                   select, mode,  
1119                                    sortKeys, withParams, false);                                    sortKeys, withParams, false);
1120    }    }
1121    
1122    /**    /**
1123     * call-template     * call-template
1124     */     */
1125    final TemplateNode parseCallTemplate(Node node, Node children, Node next)    final TemplateNode parseCallTemplate(Node node)
1126      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1127    {    {
1128      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1129      String n = getRequiredAttribute(attrs, "name", node);      String n = getRequiredAttribute(attrs, "name", node);
1130      QName name = getQName(n);      QName name = getQName(n);
1131        Node children = node.getFirstChild();
1132      List withParams = parseWithParams(children);      List withParams = parseWithParams(children);
1133      return new CallTemplateNode(null, parse(next), name,      return new CallTemplateNode(name, withParams);
                                 withParams);  
1134    }    }
1135        
1136    /**    /**
1137     * value-of     * value-of
1138     */     */
1139    final TemplateNode parseValueOf(Node node, Node children, Node next)    final TemplateNode parseValueOf(Node node)
1140      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1141    {    {
1142      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
# Line 1139  class Stylesheet Line 1144  class Stylesheet
1144      String doe = getAttribute(attrs, "disable-output-escaping");      String doe = getAttribute(attrs, "disable-output-escaping");
1145      boolean d = "yes".equals(doe);      boolean d = "yes".equals(doe);
1146      Expr select = (Expr) xpath.compile(s);      Expr select = (Expr) xpath.compile(s);
1147      return new ValueOfNode(null, parse(next), select, d);      return new ValueOfNode(select, d);
1148    }    }
1149        
1150    /**    /**
1151     * for-each     * for-each
1152     */     */
1153    final TemplateNode parseForEach(Node node, Node children, Node next)    final TemplateNode parseForEach(Node node)
1154      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1155    {    {
1156      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1157      String s = getRequiredAttribute(attrs, "select", node);      String s = getRequiredAttribute(attrs, "select", node);
1158        Node children = node.getFirstChild();
1159      List sortKeys = parseSortKeys(children);      List sortKeys = parseSortKeys(children);
1160      Expr select = (Expr) xpath.compile(s);      Expr select = (Expr) xpath.compile(s);
1161      return new ForEachNode(parse(children), parse(next), select, sortKeys);      ForEachNode ret = new ForEachNode(select, sortKeys);
1162        ret.children = parse(children);
1163        return ret;
1164    }    }
1165        
1166    /**    /**
1167     * if     * if
1168     */     */
1169    final TemplateNode parseIf(Node node, Node children, Node next)    final TemplateNode parseIf(Node node)
1170      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1171    {    {
1172      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1173      String t = getRequiredAttribute(attrs, "test", node);      String t = getRequiredAttribute(attrs, "test", node);
1174      Expr test = (Expr) xpath.compile(t);      Expr test = (Expr) xpath.compile(t);
1175      return new IfNode(parse(children), parse(next), test);      Node children = node.getFirstChild();
1176        IfNode ret = new IfNode(test);
1177        ret.children = parse(children);
1178        return ret;
1179    }    }
1180        
1181    /**    /**
1182     * when     * when
1183     */     */
1184    final TemplateNode parseWhen(Node node, Node children, Node next)    final TemplateNode parseWhen(Node node)
1185      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1186    {    {
1187      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1188      String t = getRequiredAttribute(attrs, "test", node);      String t = getRequiredAttribute(attrs, "test", node);
1189      Expr test = (Expr) xpath.compile(t);      Expr test = (Expr) xpath.compile(t);
1190      return new WhenNode(parse(children), parse(next), test);      Node children = node.getFirstChild();
1191        WhenNode ret = new WhenNode(test);
1192        ret.children = parse(children);
1193        return ret;
1194    }    }
1195        
1196    /**    /**
1197     * element     * element
1198     */     */
1199    final TemplateNode parseElement(Node node, Node children, Node next)    final TemplateNode parseElement(Node node)
1200      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1201    {    {
1202      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
# Line 1192  class Stylesheet Line 1206  class Stylesheet
1206      TemplateNode n = parseAttributeValueTemplate(name, node);      TemplateNode n = parseAttributeValueTemplate(name, node);
1207      TemplateNode ns = (namespace == null) ? null :      TemplateNode ns = (namespace == null) ? null :
1208        parseAttributeValueTemplate(namespace, node);        parseAttributeValueTemplate(namespace, node);
1209      return new ElementNode(parse(children), parse(next), n, ns, uas, node);      Node children = node.getFirstChild();
1210        ElementNode ret = new ElementNode(n, ns, uas, node);
1211        ret.children = parse(children);
1212        return ret;
1213    }    }
1214    
1215    /**    /**
1216     * attribute     * attribute
1217     */     */
1218    final TemplateNode parseAttribute(Node node, Node children, Node next)    final TemplateNode parseAttribute(Node node)
1219      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1220    {    {
1221      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
# Line 1207  class Stylesheet Line 1224  class Stylesheet
1224      TemplateNode n = parseAttributeValueTemplate(name, node);      TemplateNode n = parseAttributeValueTemplate(name, node);
1225      TemplateNode ns = (namespace == null) ? null :      TemplateNode ns = (namespace == null) ? null :
1226        parseAttributeValueTemplate(namespace, node);        parseAttributeValueTemplate(namespace, node);
1227      return new AttributeNode(parse(children), parse(next), n, ns, node);      Node children = node.getFirstChild();
1228        AttributeNode ret = new AttributeNode(n, ns, node);
1229        ret.children = parse(children);
1230        return ret;
1231    }    }
1232        
1233    /**    /**
1234     * text     * text
1235     */     */
1236    final TemplateNode parseText(Node node, Node children, Node next)    final TemplateNode parseText(Node node)
1237      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1238    {    {
1239      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1240      String doe = getAttribute(attrs, "disable-output-escaping");      String doe = getAttribute(attrs, "disable-output-escaping");
1241      boolean d = "yes".equals(doe);      boolean d = "yes".equals(doe);
1242      return new TextNode(parse(children), parse(next), d);      Node children = node.getFirstChild();
1243        TextNode ret = new TextNode(d);
1244        ret.children = parse(children);
1245        return ret;
1246    }    }
1247        
1248    /**    /**
1249     * copy     * copy
1250     */     */
1251    final TemplateNode parseCopy(Node node, Node children, Node next)    final TemplateNode parseCopy(Node node)
1252      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1253    {    {
1254      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1255      String uas = getAttribute(attrs, "use-attribute-sets");      String uas = getAttribute(attrs, "use-attribute-sets");
1256      return new CopyNode(parse(children), parse(next), uas);      Node children = node.getFirstChild();
1257        CopyNode ret = new CopyNode(uas);
1258        ret.children = parse(children);
1259        return ret;
1260    }    }
1261        
1262    /**    /**
1263     * processing-instruction     * processing-instruction
1264     */     */
1265    final TemplateNode parseProcessingInstruction(Node node, Node children,    final TemplateNode parseProcessingInstruction(Node node)
                                                 Node next)  
1266      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1267    {    {
1268      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1269      String name = getRequiredAttribute(attrs, "name", node);      String name = getRequiredAttribute(attrs, "name", node);
1270      return new ProcessingInstructionNode(parse(children),      Node children = node.getFirstChild();
1271                                           parse(next), name);      ProcessingInstructionNode ret = new ProcessingInstructionNode(name);
1272        ret.children = parse(children);
1273        return ret;
1274    }    }
1275        
1276    /**    /**
1277     * number     * number
1278     */     */
1279    final TemplateNode parseNumber(Node node, Node children, Node next)    final TemplateNode parseNumber(Node node)
1280      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1281    {    {
1282      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
# Line 1269  class Stylesheet Line 1296  class Stylesheet
1296      String gz = getAttribute(attrs, "grouping-size");      String gz = getAttribute(attrs, "grouping-size");
1297      int gz2 = (gz != null && gz.length() > 0) ?      int gz2 = (gz != null && gz.length() > 0) ?
1298        Integer.parseInt(gz) : 1;        Integer.parseInt(gz) : 1;
1299        Node children = node.getFirstChild();
1300        TemplateNode ret;
1301      if (v != null && v.length() > 0)      if (v != null && v.length() > 0)
1302        {        {
1303          Expr value = (Expr) xpath.compile(v);          Expr value = (Expr) xpath.compile(v);
1304          return new NumberNode(parse(children), parse(next),          ret = new NumberNode(value, format, lang,
1305                                value, format, lang,                               letterValue, gs, gz2);
                               letterValue, gs, gz2);  
1306        }        }
1307      else      else
1308        {        {
# Line 1311  class Stylesheet Line 1339  class Stylesheet
1339                  throw new TransformerConfigurationException(msg);                  throw new TransformerConfigurationException(msg);
1340                }                }
1341            }            }
1342          return new NodeNumberNode(parse(children), parse(next),          ret = new NodeNumberNode(level, count, from,
1343                                    level, count, from,                                   format, lang,
1344                                    format, lang,                                   letterValue, gs, gz2);
                                   letterValue, gs, gz2);  
1345        }        }
1346        ret.children = parse(children);
1347        return ret;
1348    }    }
1349        
1350    /**    /**
1351     * copy-of     * copy-of
1352     */     */
1353    final TemplateNode parseCopyOf(Node node, Node children, Node next)    final TemplateNode parseCopyOf(Node node)
1354      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1355    {    {
1356      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1357      String s = getRequiredAttribute(attrs, "select", node);      String s = getRequiredAttribute(attrs, "select", node);
1358      Expr select = (Expr) xpath.compile(s);      Expr select = (Expr) xpath.compile(s);
1359      return new CopyOfNode(parse(children), parse(next), select);      Node children = node.getFirstChild();
1360        CopyOfNode ret = new CopyOfNode(select);
1361        ret.children = parse(children);
1362        return ret;
1363    }    }
1364        
1365    /**    /**
1366     * message     * message
1367     */     */
1368    final TemplateNode parseMessage(Node node, Node children, Node next)    final TemplateNode parseMessage(Node node)
1369      throws TransformerConfigurationException, XPathExpressionException      throws TransformerConfigurationException, XPathExpressionException
1370    {    {
1371      NamedNodeMap attrs = node.getAttributes();      NamedNodeMap attrs = node.getAttributes();
1372      String t = getAttribute(attrs, "terminate");      String t = getAttribute(attrs, "terminate");
1373      boolean terminate = "yes".equals(t);      boolean terminate = "yes".equals(t);
1374      return new MessageNode(parse(children), parse(next), terminate);      Node children = node.getFirstChild();
1375        MessageNode ret = new MessageNode(terminate);
1376        ret.children = parse(children);
1377        return ret;
1378    }    }
1379        
1380    /**    /**
# Line 1348  class Stylesheet Line 1383  class Stylesheet
1383    final TemplateNode parse(Node node)    final TemplateNode parse(Node node)
1384      throws TransformerConfigurationException      throws TransformerConfigurationException
1385    {    {
1386      if (node == null)      TemplateNode first = null;
1387        TemplateNode previous = null;
1388        while (node != null)
1389        {        {
1390          return null;          Node next = node.getNextSibling();
1391            TemplateNode tnode = doParse(node);
1392            if (tnode != null)
1393              {
1394                if (first == null)
1395                  {
1396                    first = tnode;
1397                  }
1398                if (previous != null)
1399                  {
1400                    previous.next = tnode;
1401                  }
1402                previous = tnode;
1403              }
1404            node = next;
1405        }        }
1406        return first;
1407      }
1408    
1409      private final TemplateNode doParse(Node node)
1410        throws TransformerConfigurationException
1411      {
1412      // Hack to associate the document function with its declaring node      // Hack to associate the document function with its declaring node
1413      current = node;      current = node;
     Node children = node.getFirstChild();  
     Node next = node.getNextSibling();  
1414      try      try
1415        {        {
1416          String namespaceUri = node.getNamespaceURI();          String namespaceUri = node.getNamespaceURI();
# Line 1365  class Stylesheet Line 1420  class Stylesheet
1420              String name = node.getLocalName();              String name = node.getLocalName();
1421              if ("apply-templates".equals(name))              if ("apply-templates".equals(name))
1422                {                {
1423                  return parseApplyTemplates(node, children, next);                  return parseApplyTemplates(node);
1424                }                }
1425              else if ("call-template".equals(name))              else if ("call-template".equals(name))
1426                {                {
1427                  return parseCallTemplate(node, children, next);                  return parseCallTemplate(node);
1428                }                }
1429              else if ("value-of".equals(name))              else if ("value-of".equals(name))
1430                {                {
1431                  return parseValueOf(node, children, next);                  return parseValueOf(node);
1432                }                }
1433              else if ("for-each".equals(name))              else if ("for-each".equals(name))
1434                {                {
1435                  return parseForEach(node, children, next);                  return parseForEach(node);
1436                }                }
1437              else if ("if".equals(name))              else if ("if".equals(name))
1438                {                {
1439                  return parseIf(node, children, next);                  return parseIf(node);
1440                }                }
1441              else if ("choose".equals(name))              else if ("choose".equals(name))
1442                {                {
1443                  return new ChooseNode(parse(children), parse(next));                  Node children = node.getFirstChild();
1444                    ChooseNode ret = new ChooseNode();
1445                    ret.children = parse(children);
1446                    return ret;
1447                }                }
1448              else if ("when".equals(name))              else if ("when".equals(name))
1449                {                {
1450                  return parseWhen(node, children, next);                  return parseWhen(node);
1451                }                }
1452              else if ("otherwise".equals(name))              else if ("otherwise".equals(name))
1453                {                {
1454                  return new OtherwiseNode(parse(children), parse(next));                  Node children = node.getFirstChild();
1455                    OtherwiseNode ret = new OtherwiseNode();
1456                    ret.children = parse(children);
1457                    return ret;
1458                }                }
1459              else if ("element".equals(name))              else if ("element".equals(name))
1460                {                {
1461                  return parseElement(node, children, next);                  return parseElement(node);
1462                }                }
1463              else if ("attribute".equals(name))              else if ("attribute".equals(name))
1464                {                {
1465                  return parseAttribute(node, children, next);                  return parseAttribute(node);
1466                }                }
1467              else if ("text".equals(name))              else if ("text".equals(name))
1468                {                {
1469                  return parseText(node, children, next);                  return parseText(node);
1470                }                }
1471              else if ("copy".equals(name))              else if ("copy".equals(name))
1472                {                {
1473                  return parseCopy(node, children, next);                  return parseCopy(node);
1474                }                }
1475              else if ("processing-instruction".equals(name))              else if ("processing-instruction".equals(name))
1476                {                {
1477                  return parseProcessingInstruction(node, children, next);                  return parseProcessingInstruction(node);
1478                }                }
1479              else if ("comment".equals(name))              else if ("comment".equals(name))
1480                {                {
1481                  return new CommentNode(parse(children), parse(next));                  Node children = node.getFirstChild();
1482                    CommentNode ret = new CommentNode();
1483                    ret.children = parse(children);
1484                    return ret;
1485                }                }
1486              else if ("number".equals(name))              else if ("number".equals(name))
1487                {                {
1488                  return parseNumber(node, children, next);                  return parseNumber(node);
1489                }                }
1490              else if ("param".equals(name) ||              else if ("param".equals(name) ||
1491                       "variable".equals(name))                       "variable".equals(name))
1492                {                {
1493                  boolean global = "variable".equals(name);                  boolean global = "variable".equals(name);
1494                  NamedNodeMap attrs = node.getAttributes();                  NamedNodeMap attrs = node.getAttributes();
1495                    Node children = node.getFirstChild();
1496                  TemplateNode content = parse(children);                  TemplateNode content = parse(children);
1497                  String paramName = getRequiredAttribute(attrs, "name", node);                  String paramName = getRequiredAttribute(attrs, "name", node);
1498                  String select = getAttribute(attrs, "select");                  String select = getAttribute(attrs, "select");
1499                    ParameterNode ret;
1500                  if (select != null)                  if (select != null)
1501                    {                    {
1502                      if (content != null)                      if (content != null)
# Line 1441  class Stylesheet Line 1507  class Stylesheet
1507                          throw new TransformerConfigurationException(msg, l);                          throw new TransformerConfigurationException(msg, l);
1508                        }                        }
1509                      Expr expr = (Expr) xpath.compile(select);                      Expr expr = (Expr) xpath.compile(select);
1510                      return new ParameterNode(null, parse(next),                      ret = new ParameterNode(paramName, expr, global);
                                              paramName, expr, global);  
1511                    }                    }
1512                  else                  else
1513                    {                    {
1514                      return new ParameterNode(content, parse(next),                      ret = new ParameterNode(paramName, null, global);
1515                                               paramName, null, global);                      ret.children = content;
1516                    }                    }
1517                    return ret;
1518                }                }
1519              else if ("copy-of".equals(name))              else if ("copy-of".equals(name))
1520                {                {
1521                  return parseCopyOf(node, children, next);                  return parseCopyOf(node);
1522                }                }
1523              else if ("message".equals(name))              else if ("message".equals(name))
1524                {                {
1525                  return parseMessage(node, children, next);                  return parseMessage(node);
1526                }                }
1527              else if ("apply-imports".equals(name))              else if ("apply-imports".equals(name))
1528                {                {
1529                  return new ApplyImportsNode(parse(children), parse(next));                  Node children = node.getFirstChild();
1530                    ApplyImportsNode ret = new ApplyImportsNode();
1531                    ret.children = parse(children);
1532                    return ret;
1533                }                }
1534              else              else
1535                {                {
1536                  // xsl:fallback                  // xsl:fallback
1537                  // Pass over any other XSLT nodes                  // Pass over any other XSLT nodes
1538                  return parse(next);                  return null;
1539                }                }
1540            }            }
1541          String prefix = node.getPrefix();          String prefix = node.getPrefix();
1542          if (extensionElementPrefixes.contains(prefix))          if (extensionElementPrefixes.contains(prefix))
1543            {            {
1544              // Pass over extension elements              // Pass over extension elements
1545              return parse(next);              return null;
1546            }            }
1547          switch (node.getNodeType())          switch (node.getNodeType())
1548            {            {
# Line 1484  class Stylesheet Line 1553  class Stylesheet
1553                {                {
1554                  // Strip                  // Strip
1555                  text.getParentNode().removeChild(text);                  text.getParentNode().removeChild(text);
1556                  return parse(next);                  return null;
1557                }                }
1558              break;              break;
1559            case Node.COMMENT_NODE:            case Node.COMMENT_NODE:
1560              // Ignore comments              // Ignore comments
1561              return parse(next);              return null;
1562            case Node.ELEMENT_NODE:            case Node.ELEMENT_NODE:
1563              // Check for attribute value templates and use-attribute-sets              // Check for attribute value templates and use-attribute-sets
1564              NamedNodeMap attrs = node.getAttributes();              NamedNodeMap attrs = node.getAttributes();
# Line 1519  class Stylesheet Line 1588  class Stylesheet
1588                {                {
1589                  // Create an element-producing template node instead                  // Create an element-producing template node instead
1590                  // with appropriate attribute-producing child template nodes                  // with appropriate attribute-producing child template nodes
1591                    Node children = node.getFirstChild();
1592                  TemplateNode child = parse(children);                  TemplateNode child = parse(children);
1593                  for (int i = 0; i < len; i++)                  for (int i = 0; i < len; i++)
1594                    {                    {
# Line 1537  class Stylesheet Line 1607  class Stylesheet
1607                        parseAttributeValueTemplate(aname, node);                        parseAttributeValueTemplate(aname, node);
1608                      TemplateNode ns = (ans == null) ? null :                      TemplateNode ns = (ans == null) ? null :
1609                        parseAttributeValueTemplate(ans, node);                        parseAttributeValueTemplate(ans, node);
1610                      child = new AttributeNode(grandchild, child, n, ns, attr);                      TemplateNode newChild = new AttributeNode(n, ns, attr);
1611                        newChild.children = grandchild;
1612                        newChild.next = child;
1613                        child = newChild;
1614                    }                    }
1615                  String ename = node.getNodeName();                  String ename = node.getNodeName();
1616                  TemplateNode n = parseAttributeValueTemplate(ename, node);                  TemplateNode n = parseAttributeValueTemplate(ename, node);
1617                  TemplateNode ns = (namespaceUri == null) ? null :                  TemplateNode ns = (namespaceUri == null) ? null :
1618                    parseAttributeValueTemplate(namespaceUri, node);                    parseAttributeValueTemplate(namespaceUri, node);
1619                  return new ElementNode(child, parse(next),                  ElementNode ret = new ElementNode(n, ns, useAttributeSets,
1620                                         n, ns, useAttributeSets,                                                    node);
1621                                         node);                  ret.children = child;
1622                    return ret;
1623                }                }
1624              // Otherwise fall through              // Otherwise fall through
1625              break;              break;
# Line 1556  class Stylesheet Line 1630  class Stylesheet
1630          DOMSourceLocator l = new DOMSourceLocator(node);          DOMSourceLocator l = new DOMSourceLocator(node);
1631          throw new TransformerConfigurationException(e.getMessage(), l, e);          throw new TransformerConfigurationException(e.getMessage(), l, e);
1632        }        }
1633      return new LiteralNode(parse(children), parse(next), node);      Node children = node.getFirstChild();
1634        LiteralNode ret = new LiteralNode(node);
1635        ret.children = parse(children);
1636        return ret;
1637    }    }
1638    
1639    final List parseSortKeys(Node node)    final List parseSortKeys(Node node)

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26