Re: [xslt] Bug(s) in tests/REC/test-7.7-4.out and numbering?



Le 2001.10.09 23:15, Daniel Veillard a écrit :
> > Isn't there a bug in tests/REC/test-7.7-4.out?
> 
>   yes it's a bug I fixed earlier this week but I didn't commited the
> change of output. go ahead !

Commited

> > It also seems there is a bug in xsl:number implementation as there
> > isn't any opening brace before the number: output is "1) " while format
> > is "(1) ".
> 
>   Possible, yes, if you want to fix it ...

As far as I understand the existing code, it needs to be totally reworked.
Or maybe we can just always use the first xsltNumberFormatToken in the list
to store the "non-alphanumeric start token".
I have to admit I'm a bit lost in this code, not much documented and quite
obscure for my eyes...

I'm a partisan of really easy-to-read code and exact transposition of the
specs. Here is the (almost) exact transposition of the spec:

typedef struct _xsltNumberFormat xsltNumberFormat;
typedef struct _xsltFormatToken xsltFormatToken;
typedef struct _xsltNumberFormatToken xsltNumberFormatToken;

/**
 * the tokenized format
 */
struct _xsltNumberFormat {
    xmlChar               *start;  /* non-alphanumeric start token */
    xsltFormatToken        first;  /* first format token */
    xsltNumberFormatToken *tokens; /* following format token with their
                                      preceding separator */
    int                    nTokens;/* number of «tokens» */
    xmlChar               *end;    /* non-alphanumeric end token */
};

/**
 * a format token
 */
struct _xsltFormatToken {
    xmlChar token;
    int     width;                 /* used only if token is numeric */
};

/**
 * a format token and its preceding separator token
 */
struct _xsltNumberFormatToken {
    xmlChar         separator;
    xsltFormatToken format;
};

To simplify the whole thing, we can merge xsltFormatToken and
xsltNumberFormatToken (and the «first» format token doesn't use the
separator field). My representation of a tokenized format would have been:

typedef struct _xsltNumberFormat xsltNumberFormat;
typedef struct _xsltNumberFormatToken xsltNumberFormatToken;

/**
 * the tokenized format
 */
struct _xsltNumberFormat {
    xmlChar               *start;
    xsltNumberFormatToken *tokens;
    int                    nTokens;
    xmlChar               *end;
};

struct _xsltNumberFormatToken {
    xmlChar *separator;
    xmlChar  token;
    int      width;
};

It's not too late but it represents a sensible amount of work. If Bjorn
could spend some time fixing its code (see suggestion on the top of this
message), it might be better... I'll try to do it myself but I can't
promise anything, as I'll first have to understand how everything works...

Tom.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]