You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/01/26 18:01:49 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/templates ElemLiteralResult.java

sboag       01/01/26 09:01:49

  Modified:    java/src/org/apache/xalan/processor XSLTElementDef.java
                        XSLTElementProcessor.java XSLTSchema.java
               java/src/org/apache/xalan/templates ElemLiteralResult.java
  Log:
  Fixed problem with non-namespaced attributes not being properly
  validated.  Also fixed test whitespace20, which I guess worked
  before??  It copies xml:space attributes to the result, and these
  were being lost.
  
  Revision  Changes    Path
  1.11      +5 -4      xml-xalan/java/src/org/apache/xalan/processor/XSLTElementDef.java
  
  Index: XSLTElementDef.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/XSLTElementDef.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XSLTElementDef.java	2001/01/12 07:32:39	1.10
  +++ XSLTElementDef.java	2001/01/26 17:01:46	1.11
  @@ -410,12 +410,13 @@
         XSLTAttributeDef attrDef = attrDefs[k];
         String uriDef = attrDef.getNamespace();
         String nameDef = attrDef.getName();
  -
  -      if (nameDef.equals("*") && equalsMayBeNullOrZeroLen(uri, uriDef))
  +      
  +      if (nameDef.equals("*") && (equalsMayBeNullOrZeroLen(uri, uriDef) || 
  +          (uriDef != null && uri.length() > 0 && uriDef.equals("*"))))
         {
           return attrDef;
         }
  -      else if (nameDef.equals("*"))
  +      else if (nameDef.equals("*") && (uriDef == null))
         {
   
           // In this case, all attributes are legal, so return 
  @@ -431,7 +432,7 @@
   
       if (null == defaultDef)
       {
  -      if (!equalsMayBeNullOrZeroLen(uri, Constants.S_XSLNAMESPACEURL))
  +      if (uri.length() > 0 && !equalsMayBeNullOrZeroLen(uri, Constants.S_XSLNAMESPACEURL))
         {
           return XSLTAttributeDef.m_foreignAttr;
         }
  
  
  
  1.8       +2 -2      xml-xalan/java/src/org/apache/xalan/processor/XSLTElementProcessor.java
  
  Index: XSLTElementProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/XSLTElementProcessor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XSLTElementProcessor.java	2000/11/22 23:26:00	1.7
  +++ XSLTElementProcessor.java	2001/01/26 17:01:46	1.8
  @@ -339,8 +339,8 @@
           {
   
             // Then barf, because this element does not allow this attribute.
  -          handler.error(attributes.getQName(i)
  -                        + "attribute is not allowed on the " + rawName
  +          handler.error("\""+attributes.getQName(i)+"\""
  +                        + " attribute is not allowed on the " + rawName
                           + " element!", null);
           }
           else
  
  
  
  1.16      +4 -0      xml-xalan/java/src/org/apache/xalan/processor/XSLTSchema.java
  
  Index: XSLTSchema.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/XSLTSchema.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XSLTSchema.java	2000/12/18 14:06:06	1.15
  +++ XSLTSchema.java	2001/01/26 17:01:47	1.16
  @@ -180,6 +180,9 @@
         new XSLTAttributeDef(Constants.S_XMLNAMESPACEURI, "space", false,
                              "default", Constants.ATTRVAL_STRIP, "preserve",
                              Constants.ATTRVAL_PRESERVE);
  +    XSLTAttributeDef spaceAttrLiteral =
  +      new XSLTAttributeDef(Constants.S_XMLNAMESPACEURI, "space", 
  +                                          XSLTAttributeDef.T_AVT, false);
       XSLTAttributeDef stylesheetPrefixAttr = new XSLTAttributeDef(null,
                                                 "stylesheet-prefix",
                                                 XSLTAttributeDef.T_CDATA, true);
  @@ -272,6 +275,7 @@
                                        null /*alias */,
                                        templateElementsAndParams /* elements */,
                                        new XSLTAttributeDef[]{
  +                                       spaceAttrLiteral, // special
                                          xslExcludeResultPrefixesAttr,
                                          xslExtensionElementPrefixesAttr,
                                          xslUseAttributeSetsAttr,
  
  
  
  1.20      +28 -0     xml-xalan/java/src/org/apache/xalan/templates/ElemLiteralResult.java
  
  Index: ElemLiteralResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemLiteralResult.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ElemLiteralResult.java	2001/01/02 03:36:46	1.19
  +++ ElemLiteralResult.java	2001/01/26 17:01:48	1.20
  @@ -160,6 +160,34 @@
   
       m_xslAttr.addElement(att);
     }
  +  
  +  /**
  +   * Set the "xml:space" attribute.
  +   * A text node is preserved if an ancestor element of the text node
  +   * has an xml:space attribute with a value of preserve, and
  +   * no closer ancestor element has xml:space with a value of default.
  +   * @see <a href="http://www.w3.org/TR/xslt#strip">strip in XSLT Specification</a>
  +   * @see <a href="http://www.w3.org/TR/xslt#section-Creating-Text">section-Creating-Text in XSLT Specification</a>
  +   *
  +   * @param v  Enumerated value, either Constants.ATTRVAL_PRESERVE 
  +   * or Constants.ATTRVAL_STRIP.
  +   */
  +  public void setXmlSpace(AVT avt)
  +  {
  +    // This function is a bit-o-hack, I guess...
  +    addLiteralResultAttribute(avt);
  +    String val = avt.getSimpleString();
  +    if(val.equals("default"))
  +    {
  +      super.setXmlSpace(Constants.ATTRVAL_STRIP);
  +    }
  +    else if(val.equals("preserve"))
  +    {
  +      super.setXmlSpace(Constants.ATTRVAL_PRESERVE);
  +    }
  +    // else maybe it's a real AVT, so we can't resolve it at this time.
  +  }
  +
   
     /**
      * Get a literal result attribute by name.