+Tue Jan 30 18:55:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * tests/REC/test-7.*: added more tests
+ * libxslt/namespaces.[ch] libxslt/pattern.c libxslt/attributes.c
+ libxslt/templates.c libxslt/transform.c libxslt/xslt.c: fixing bugs
+ raised by said tests
+
Tue Jan 30 15:16:56 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* TODO: updated
list = cur->children;
delete = NULL;
while (list != NULL) {
- if (IS_XSLT_ELEM(cur)) {
- if (!IS_XSLT_NAME(cur, "attribute")) {
+ if (IS_XSLT_ELEM(list)) {
+ if (!IS_XSLT_NAME(list, "attribute")) {
xsltGenericError(xsltGenericErrorContext,
"xslt:attribute-set : unexpected child xsl:%s\n",
- cur->name);
- delete = cur;
+ list->name);
+ delete = list;
} else {
#ifdef DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
"add attribute to list %s\n", ncname);
#endif
- values = xsltAddAttrElemList(values, cur);
+ values = xsltAddAttrElemList(values, list);
}
} else {
xsltGenericError(xsltGenericErrorContext,
- "xslt:attribute-set : unexpected child %s\n", cur->name);
- delete = cur;
+ "xslt:attribute-set : unexpected child %s\n", list->name);
+ delete = list;
}
list = list->next;
}
prop = NULL;
prefix = NULL;
}
- if (xmlStrEqual(ncname, (const xmlChar *) "xmlns")) {
- xsltGenericError(xsltGenericErrorContext,
- "xslt:attribute : xmlns forbidden\n");
+ if ((prefix != NULL) && (xmlStrEqual(prefix, (const xmlChar *)"xmlns"))) {
+#ifdef DEBUG_PARSING
+ xsltGenericDebug(xsltGenericDebugContext,
+ "xslt:attribute : xmlns prefix forbidden\n");
+#endif
goto error;
}
prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"namespace");
if (prop != NULL) {
TODO /* xsl:attribute namespace */
- xmlFree(prop);
- return;
} else {
if (prefix != NULL) {
ns = xmlSearchNs(inst->doc, inst, prefix);
if ((ctxt == NULL) || (cur == NULL) || (out == NULL) || (ns == NULL))
return(NULL);
- if ((out->type == XML_ELEMENT_NODE) && (out->ns != NULL) &&
- ((out->ns->href != NULL) && (ns->href != NULL) &&
- (xmlStrEqual(out->ns->href, ns->href)))) {
- return(out->ns);
- }
/* TODO apply cascading */
if (ctxt->style->nsAliases != NULL) {
} else
URI = ns->href;
- ret = xmlSearchNsByHref(out->doc, out, URI);
+ if ((out->parent != NULL) &&
+ (out->parent->type == XML_ELEMENT_NODE) &&
+ (out->parent->ns != NULL) &&
+ (xmlStrEqual(out->parent->ns->href, URI)))
+ ret = out->parent->ns;
+ else
+ ret = xmlSearchNsByHref(out->doc, out, URI);
+
if (ret == NULL) {
if (out->type == XML_ELEMENT_NODE)
- ret = xmlNewNs(out, ns->href, ns->prefix);
+ ret = xmlNewNs(out, URI, ns->prefix);
}
return(ret);
}
return(ret);
}
+
+/**
+ * xsltFreeNamespaceAliasHashes:
+ * @style: an XSLT stylesheet
+ *
+ * Free up the memory used by namespaces aliases
+ */
+void
+xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style) {
+ if (style->nsAliases != NULL)
+ xmlHashFree((xmlHashTablePtr) style->nsAliases, NULL);
+ style->nsAliases = NULL;
+}
xmlNsPtr xsltCopyNamespaceList (xsltTransformContextPtr ctxt,
xmlNodePtr node,
xmlNsPtr cur);
+void xsltFreeNamespaceAliasHashes(xsltStylesheetPtr style);
#ifdef __cplusplus
}
#endif
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
- return(NULL);
+ break;
default:
return(NULL);
#include "templates.h"
#include "transform.h"
#include "namespaces.h"
+#include "attributes.h"
#define DEBUG_TEMPLATES
if ((cur->ns != NULL) &&
(xmlStrEqual(cur->ns->href, XSLT_NAMESPACE))) {
- /* TODO: check for replacement namespaces */
- return(NULL);
+ if (xmlStrEqual(cur->name, (const xmlChar *)"use-attribute-sets")) {
+ xmlChar *in;
+
+ in = xmlNodeListGetString(ctxt->doc, cur->children, 1);
+ if (in != NULL) {
+ xsltApplyAttributeSet(ctxt, ctxt->node, NULL, in);
+ xmlFree(in);
+ }
+ return(NULL);
+
+ }
}
+ /* TODO: check for replacement namespaces */
ret = xmlNewDocProp(ctxt->output, cur->name, NULL);
if (ret == NULL) return(NULL);
xmlNodePtr target, xmlAttrPtr cur) {
xmlAttrPtr ret = NULL;
xmlAttrPtr p = NULL,q;
+ xmlNodePtr oldInsert;
+ oldInsert = ctxt->insert;
+ ctxt->insert = target;
while (cur != NULL) {
q = xsltAttrTemplateProcess(ctxt, target, cur);
if (q != NULL) {
}
cur = cur->next;
}
+ ctxt->insert = oldInsert;
return(ret);
}
#include "transform.h"
#include "variables.h"
#include "namespaces.h"
+#include "attributes.h"
#include "templates.h"
#define DEBUG_PROCESS
xmlNodePtr list) {
xmlNodePtr cur = NULL, insert, copy = NULL;
xmlNodePtr oldInsert;
+ xmlAttrPtr attrs;
int has_variables = 0;
CHECK_STOPPED;
copy = xsltCopyNode(ctxt, cur, insert);
/*
* all the attributes are directly inherited
- * TODO: Do the substitution of {} XPath expressions !!!
*/
- if (cur->properties != NULL)
- copy->properties = xsltAttrListTemplateProcess(ctxt,
- copy, cur->properties);
+ if (cur->properties != NULL) {
+ attrs = xsltAttrListTemplateProcess(ctxt, copy,
+ cur->properties);
+ if (copy->properties != NULL) {
+ xmlAttrPtr cur = copy->properties;
+ while (cur->next != NULL)
+ cur = cur->next;
+ cur->next = attrs;
+ } else
+ copy->properties = attrs;
+ }
}
/*
void
xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
xsltTemplatePtr template;
+ xmlNodePtr oldNode;
template = xsltGetTemplate(ctxt->style, node);
/*
return;
}
+ oldNode = ctxt->node;
+ ctxt->node = node;
xsltApplyOneTemplate(ctxt, node, template->content);
+ ctxt->node = oldNode;
}
/**
xsltFreeDecimalFormatList(sheet);
xsltFreeTemplateList(sheet->templates);
xsltFreeAttributeSetsHashes(sheet);
+ xsltFreeNamespaceAliasHashes(sheet);
if (sheet->doc != NULL)
xmlFreeDoc(sheet->doc);
if (sheet->variables != NULL)
--- /dev/null
+<?xml version="1.0"?>
+<axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform">
+<axsl:template match="p"><fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"><axsl:apply-templates/></fo:block></axsl:template>
+<axsl:template match="h1"><fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"><axsl:apply-templates/></fo:block></axsl:template>
+<axsl:template match="h2"><fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"><axsl:apply-templates/></fo:block></axsl:template>
+<axsl:template match="h3"><fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"><axsl:apply-templates/></fo:block></axsl:template>
+<axsl:template match="h4"><fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"><axsl:apply-templates/></fo:block></axsl:template>
+</axsl:stylesheet>
--- /dev/null
+<elements>
+<block>p</block>
+<block>h1</block>
+<block>h2</block>
+<block>h3</block>
+<block>h4</block>
+</elements>
--- /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"
+ xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
+
+<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
+
+<xsl:template match="/">
+ <axsl:stylesheet>
+ <xsl:apply-templates/>
+ </axsl:stylesheet>
+</xsl:template>
+
+<xsl:template match="block">
+ <axsl:template match="{.}">
+ <fo:block><axsl:apply-templates/></fo:block>
+ </axsl:template>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+<doc attr="value"/>
--- /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"
+ xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
+
+<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
+
+<xsl:template match="doc">
+<doc>
+<xsl:attribute name="xmlns:xsl" namespace="whatever">http://www.w3.org/1999/XSL/Transform</xsl:attribute>
+<xsl:attribute name="attr">value</xsl:attribute>
+<!--
+<xsl:attribute name="a">x
+y</xsl:attribute>
+-->
+</doc>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+
+
+
+<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" font-size="12pt" font-weight="bold" quadding="start">this is the heading</fo:block>
+
+
+
--- /dev/null
+<doc>
+<chapter>
+<heading>this is the heading</heading>
+</chapter>
+</doc>
--- /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"
+ xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
+
+<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
+
+<xsl:template match="chapter/heading">
+ <fo:block quadding="start" xsl:use-attribute-sets="title-style">
+ <xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+<xsl:attribute-set name="title-style">
+ <xsl:attribute name="font-size">12pt</xsl:attribute>
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
+</xsl:attribute-set>
+</xsl:stylesheet>