+Wed Feb 14 19:13:33 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
+
+ * libxslt/numbers.c: implemented level=any
+ * libxslt/transform.c: corrected some default values
+ * tests/REC/test-7.7-*.*: added
+
Wed Feb 14 18:07:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libxslt/pattern.c: priorities were horribly broken, hope it's
double *array,
int max)
{
- /* preceding | ancestor-or-self */
- TODO;
- return 0;
+ int amount = 0;
+ int cnt = 0;
+ int keep_going = TRUE;
+ xmlNodePtr ancestor;
+ xmlNodePtr preceding;
+ xmlXPathParserContextPtr parser;
+
+ context->xpathCtxt->node = node;
+ parser = xmlXPathNewParserContext(NULL, context->xpathCtxt);
+ if (parser) {
+ /* preceding */
+ for (preceding = xmlXPathNextPreceding(parser, node);
+ preceding != NULL;
+ preceding = xmlXPathNextPreceding(parser, preceding)) {
+ if ((from != NULL) &&
+ xsltMatchPattern(context, preceding, from)) {
+ keep_going = FALSE;
+ break; /* for */
+ }
+ if (count == NULL) {
+ if ((node->type == preceding->type) &&
+ /* FIXME: must use expanded-name instead of local name */
+ xmlStrEqual(node->name, preceding->name))
+ cnt++;
+ } else {
+ if (xsltMatchPattern(context, preceding, count))
+ cnt++;
+ }
+ }
+
+ if (keep_going) {
+ /* ancestor-or-self */
+ for (ancestor = node;
+ ancestor != NULL;
+ ancestor = xmlXPathNextAncestor(parser, ancestor)) {
+ if ((from != NULL) &&
+ xsltMatchPattern(context, ancestor, from)) {
+ break; /* for */
+ }
+ if (count == NULL) {
+ if ((node->type == ancestor->type) &&
+ /* FIXME */
+ xmlStrEqual(node->name, ancestor->name))
+ cnt++;
+ } else {
+ if (xsltMatchPattern(context, ancestor, count))
+ cnt++;
+ }
+ }
+ }
+ array[amount++] = (double)cnt;
+ }
+ return amount;
}
static int
preceding != NULL;
preceding = xmlXPathNextPrecedingSibling(parser, preceding)) {
if (count == NULL) {
- if (preceding->type == ancestor->type)
+ if ((preceding->type == ancestor->type) &&
+ /* FIXME */
+ xmlStrEqual(preceding->name, ancestor->name))
cnt++;
} else {
if (xsltMatchPattern(context, preceding, count))
output);
}
} else if (xmlStrEqual(data->level, "any")) {
- double numarray[1024];
- int max = sizeof(numarray)/sizeof(numarray[0]);
amount = xsltNumberFormatGetAnyLevel(ctxt,
node,
data->count,
data->from,
- numarray,
- max);
+ &number,
+ 1);
if (amount > 0) {
xsltNumberFormatInsertNumbers(data,
- numarray,
- amount,
+ &number,
+ 1,
&array,
array_amount,
output);
numdata.groupingCharacter = 0;
}
+ /* Set default values */
+ if (numdata.value == NULL) {
+ if (numdata.level == NULL) {
+ numdata.level = xmlStrdup(BAD_CAST("single"));
+ }
+ }
+
xsltNumberFormat(ctxt, &numdata, node);
if (numdata.level != NULL)
test-7.6.1-2.out test-7.6.1-2.xml test-7.6.1-2.xsl \
test-7.6.1-3.out test-7.6.1-3.xml test-7.6.1-3.xsl \
test-7.6.2-1.out test-7.6.2-1.xml test-7.6.2-1.xsl \
+ test-7.7-1.out test-7.7-1.xml test-7.7-1.xsl \
+ test-7.7-2.out test-7.7-2.xml test-7.7-2.xsl \
+ test-7.7-3.out test-7.7-3.xml test-7.7-3.xsl \
+ test-7.7-4.out test-7.7-4.xml test-7.7-4.xsl \
+ test-7.7-5.out test-7.7-5.xml test-7.7-5.xsl \
test-8-1.out test-8-1.xml test-8-1.xsl \
test-9.1-1.out test-9.1-1.xml test-9.1-1.xsl \
test-9.1-2.out test-9.1-2.xml test-9.1-2.xsl \
--- /dev/null
+<?xml version="1.0"?>
+<p>1. First</p>
+<p>2. Fourth</p>
+<p>3. Second</p>
+<p>4. Third</p>
--- /dev/null
+<items>
+ <item>First</item>
+ <item>Second</item>
+ <item>Third</item>
+ <item>Fourth</item>
+</items>
--- /dev/null
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="items">
+ <xsl:for-each select="item">
+ <xsl:sort select="."/>
+ <p>
+ <xsl:number value="position()" format="1. "/>
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:for-each>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1. First</fo:block>
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">2. Second</fo:block>
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">3. Third</fo:block>
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">4. Fourth</fo:block>
+
+
+
--- /dev/null
+<list>
+ <ol>
+ <item>First</item>
+ <item>Second</item>
+ <item>Third</item>
+ <item>Fourth</item>
+ </ol>
+</list>
--- /dev/null
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<xsl:template match="ol/item">
+ <fo:block>
+ <xsl:number/><xsl:text>. </xsl:text><xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.First Chapter</fo:block>
+
+ Here is some text.
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.1 First Chapter, First Section</fo:block>
+
+ More text here.
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.1 First Chapter, First Section, First Subsection</fo:block>
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.1 First Chapter, First Section, Second Subsection</fo:block>
+
+
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">2.Second Chapter</fo:block>
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">A.First Appendix</fo:block>
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">A.1 First Appendix, First Section</fo:block>
+
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">B.Second Appendix</fo:block>
+
+
+
--- /dev/null
+<book>
+ <chapter>
+ <title>First Chapter</title>
+ Here is some text.
+ <section>
+ <title>First Chapter, First Section</title>
+ More text here.
+ <subsection>
+ <title>First Chapter, First Section, First Subsection</title>
+ </subsection>
+ <subsection>
+ <title>First Chapter, First Section, Second Subsection</title>
+ </subsection>
+ </section>
+ </chapter>
+ <chapter>
+ <title>Second Chapter</title>
+ </chapter>
+ <appendix>
+ <title>First Appendix</title>
+ <section>
+ <title>First Appendix, First Section</title>
+ </section>
+ </appendix>
+ <appendix>
+ <title>Second Appendix</title>
+ </appendix>
+</book>
--- /dev/null
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<xsl:template match="title">
+ <fo:block>
+ <xsl:number level="multiple"
+ count="chapter|section|subsection"
+ format="1.1 "/>
+ <xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+<xsl:template match="appendix//title" priority="1">
+ <fo:block>
+ <xsl:number level="multiple"
+ count="appendix|section|subsection"
+ format="A.1 "/>
+ <xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1) A note here</fo:block>
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">2) And here</fo:block>
+
+
+
+
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">2) And another note here</fo:block>
+
+
+
--- /dev/null
+<book>
+ <chapter>
+ <section>
+ <subsection>
+ <note>A note here</note>
+ <note>And here</note>
+ </subsection>
+ <subsection>
+ </subsection>
+ </section>
+ </chapter>
+ <chapter>
+ <note>And another note here</note>
+ </chapter>
+</book>
--- /dev/null
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<xsl:template match="note">
+ <fo:block>
+ <xsl:number level="any" from="chapter" format="(1) "/>
+ <xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.1.1 one</fo:block>
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.1.2 two</fo:block>
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">1.1.3 three</fo:block>
+
+
+
+
--- /dev/null
+<H1>
+ <H2>
+ <H3>
+ <H4>one</H4>
+ <H4>two</H4>
+ <H4>three</H4>
+ </H3>
+ </H2>
+</H1>
--- /dev/null
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<xsl:template match="H4">
+ <fo:block>
+ <xsl:number level="any" from="H1" count="H2"/>
+ <xsl:text>.</xsl:text>
+ <xsl:number level="any" from="H2" count="H3"/>
+ <xsl:text>.</xsl:text>
+ <xsl:number level="any" from="H3" count="H4"/>
+ <xsl:text> </xsl:text>
+ <xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+</xsl:stylesheet>