On Fri, Sep 07, 2012 at 08:35:34AM -0400, Phil Shafer wrote:
> Daniel Veillard writes:
> >  I tagged the git and pushed a tarball of the rc1 to:
> >   ftp://xmlsoft.org/libxslt/
> 
> Please consider this patch that adds append functionality to
> the <redirect:write> element via the "append" attribute.
> This attribute is already supported in Xalan and SAXON.

  Just wondering, shouldn't that attribute be namespaced ? 
Where is this described ?

> 
> Index: branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/transform.c
> ===================================================================
> --- branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/transform.c     
> (revision 384559)
> +++ branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/transform.c     
> (revision 384560)
> @@ -3216,6 +3215,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xml
>      const xmlChar *doctypePublic;
>      const xmlChar *doctypeSystem;
>      const xmlChar *version;
> +    int redirect_write_append = 0;
>  
>      if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
>          return;
> @@ -3630,10 +3630,25 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xml
>      }
>  
>      /*
> -     * Save the result
> +     * Calls to redirect:write also take an optional attribute append.
> +     * Attribute append="true|yes" which will attempt to simply append
> +     * to an existing file instead of always opening a new file. The
> +     * default behavior of always overwriting the file still happens
> +     * if we donot specify append.
>       */
> +    prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"append",
> +                                  NULL);
> +    if (prop != NULL) {
> +     if (xmlStrEqual(prop, (const xmlChar *) "true") ||
> +         xmlStrEqual(prop, (const xmlChar *) "yes")) {
> +         style->omitXmlDeclaration = 1;
> +         redirect_write_append = 1;
> +     } else
> +         style->omitXmlDeclaration = 0;
> +    }
> +
>      ret = xsltSaveResultToFilename((const char *) filename,
> -                                   res, style, 0);
> +                                   res, style, 0, redirect_write_append);
>      if (ret < 0) {
>       xsltTransformError(ctxt, NULL, inst,
>                           "xsltDocumentElem: unable to save to %s\n",
> @@ -6339,7 +6354,7 @@ xsltRunStylesheetUser(xsltStylesheetPtr style, xml
>          /* TODO: incomplete, IObuf output not progressive */
>          ret = xsltSaveResultTo(IObuf, tmp, style);
>      } else {
> -        ret = xsltSaveResultToFilename(output, tmp, style, 0);
> +        ret = xsltSaveResultToFilename(output, tmp, style, 0, 0);
>      }
>      xmlFreeDoc(tmp);
>      return (ret);
> Index: branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/xsltutils.c
> ===================================================================
> --- branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/xsltutils.c     
> (revision 384559)
> +++ branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/xsltutils.c     
> (revision 384560)
> @@ -1582,7 +1582,7 @@ xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr
>   */
>  int
>  xsltSaveResultToFilename(const char *URL, xmlDocPtr result,
> -                      xsltStylesheetPtr style, int compression) {
> +                      xsltStylesheetPtr style, int compression, int mode) {

  That we cant do it changes a public API, we need a new function to
add the mode.

>      xmlOutputBufferPtr buf;
>      const xmlChar *encoding;
>      int ret;
> @@ -1601,9 +1601,9 @@ xsltSaveResultToFilename(const char *URL, xmlDocPt
>           (xmlStrEqual((const xmlChar *)encoder->name,
>                        (const xmlChar *) "UTF-8")))
>           encoder = NULL;
> -     buf = xmlOutputBufferCreateFilename(URL, encoder, compression);
> +     buf = xmlOutputBufferCreateFilename(URL, encoder, compression, mode);
>      } else {
> -     buf = xmlOutputBufferCreateFilename(URL, NULL, compression);
> +     buf = xmlOutputBufferCreateFilename(URL, NULL, compression, mode);
>      }
>      if (buf == NULL)
>       return(-1);
> Index: branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/xsltutils.h
> ===================================================================
> --- branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/xsltutils.h     
> (revision 384559)
> +++ branches/IB4_10_5_BRANCH/gpl-dist/libxslt/libxslt/xsltutils.h     
> (revision 384560)
> @@ -221,7 +221,8 @@ XSLTPUBFUN int XSLTCALL
>               xsltSaveResultToFilename        (const char *URI,
>                                                xmlDocPtr result,
>                                                xsltStylesheetPtr style,
> -                                              int compression);
> +                                              int compression,
> +                                              int mode);
>  XSLTPUBFUN int XSLTCALL              
>               xsltSaveResultToFile            (FILE *file,
>                                                xmlDocPtr result,
> Index: branches/IB4_10_5_BRANCH/dist/php/ext/dom/node.c
> ===================================================================
> --- branches/IB4_10_5_BRANCH/dist/php/ext/dom/node.c  (revision 384559)
> +++ branches/IB4_10_5_BRANCH/dist/php/ext/dom/node.c  (revision 384560)
> @@ -1807,7 +1807,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION
>       }
>  
>       if (mode == 1) {
> -             buf = xmlOutputBufferCreateFilename(file, NULL, 0);
> +             buf = xmlOutputBufferCreateFilename(file, NULL, 0, 0);
>       } else {
>               buf = xmlAllocOutputBuffer(NULL);
>       }

  Err, what is this ?

> Index: branches/IB4_10_5_BRANCH/dist/php/ext/xsl/xsltprocessor.c
> ===================================================================
> --- branches/IB4_10_5_BRANCH/dist/php/ext/xsl/xsltprocessor.c (revision 
> 384559)
> +++ branches/IB4_10_5_BRANCH/dist/php/ext/xsl/xsltprocessor.c (revision 
> 384560)
> @@ -551,7 +551,7 @@ PHP_FUNCTION(xsl_xsltprocessor_transform_to_uri)
>  
>       ret = -1;
>       if (newdocp) {
> -             ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0);
> +             ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0, 0);
>               xmlFreeDoc(newdocp);
>       }
>  
> Index: branches/IB4_10_5_BRANCH/dist/php/ext/simplexml/simplexml.c
> ===================================================================
> --- branches/IB4_10_5_BRANCH/dist/php/ext/simplexml/simplexml.c       
> (revision 384559)
> +++ branches/IB4_10_5_BRANCH/dist/php/ext/simplexml/simplexml.c       
> (revision 384560)
> @@ -1247,7 +1247,7 @@ SXE_METHOD(asXML)
>                                       RETURN_TRUE;
>                               }
>                       } else {
> -                             outbuf = 
> xmlOutputBufferCreateFilename(filename, NULL, 0);
> +                             outbuf = 
> xmlOutputBufferCreateFilename(filename, NULL, 0, 0);
>  
>                               if (outbuf == NULL) {
>                                       RETURN_FALSE;
> Index: branches/IB4_10_5_BRANCH/dist/libxml2/include/libxml/xmlIO.h
> ===================================================================
> --- branches/IB4_10_5_BRANCH/dist/libxml2/include/libxml/xmlIO.h      
> (revision 384559)
> +++ branches/IB4_10_5_BRANCH/dist/libxml2/include/libxml/xmlIO.h      
> (revision 384560)
> @@ -86,7 +86,7 @@ typedef int (XMLCALL *xmlOutputMatchCallback) (cha
>   *
>   * Returns an Output context or NULL in case or error
>   */
> -typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
> +typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename, int 
> mode);
>  /**
>   * xmlOutputWriteCallback:
>   * @context:  an Output context
> @@ -225,7 +225,7 @@ XMLPUBFUN xmlOutputBufferPtr XMLCALL
>  XMLPUBFUN xmlOutputBufferPtr XMLCALL
>       xmlOutputBufferCreateFilename   (const char *URI,
>                                        xmlCharEncodingHandlerPtr encoder,
> -                                      int compression);
> +                                      int compression, int mode);

  Changing public APIs of libxml2 too, sorry that's unrealistic ...


  What does this actually do ? maybe the implementation can be done
in libxslt, but your current patch is really unusable as-is, sorry !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[email protected]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
https://mail.gnome.org/mailman/listinfo/xslt

Reply via email to