[gs-cvs] rev 8850 - trunk/ghostpdl/xps
tor at ghostscript.com
tor at ghostscript.com
Thu Jul 17 10:40:35 PDT 2008
Author: tor
Date: 2008-07-17 10:40:34 -0700 (Thu, 17 Jul 2008)
New Revision: 8850
Modified:
trunk/ghostpdl/xps/xpsresource.c
trunk/ghostpdl/xps/xpsxml.c
Log:
Handle namespaced attributes in the XML. This should solve a whole batch of problems introduced with the previous namespace patch, since resource dictionaries were not being parsed correctly. (x:Key attributes were not recognized)
Modified: trunk/ghostpdl/xps/xpsresource.c
===================================================================
--- trunk/ghostpdl/xps/xpsresource.c 2008-07-17 08:42:19 UTC (rev 8849)
+++ trunk/ghostpdl/xps/xpsresource.c 2008-07-17 17:40:34 UTC (rev 8850)
@@ -97,7 +97,8 @@
for (node = xps_down(root); node; node = xps_next(node))
{
- key = xps_att(node, "x:Key");
+ /* Usually "x:Key"; we have already processed and stripped namespace */
+ key = xps_att(node, "Key");
if (key)
{
entry = xps_alloc(ctx, sizeof(xps_resource_t));
Modified: trunk/ghostpdl/xps/xpsxml.c
===================================================================
--- trunk/ghostpdl/xps/xpsxml.c 2008-07-17 08:42:19 UTC (rev 8849)
+++ trunk/ghostpdl/xps/xpsxml.c 2008-07-17 17:40:34 UTC (rev 8850)
@@ -29,6 +29,14 @@
xps_item_t *next;
};
+static char *skip_namespace(char *s)
+{
+ char *p = strchr(s, ' ');
+ if (p)
+ return p + 1;
+ return s;
+}
+
static void on_open_tag(void *zp, const char *ns_name, const char **atts)
{
xps_parser_t *parser = zp;
@@ -75,7 +83,10 @@
for (i = 0; atts[i]; i++)
{
attslen += sizeof(char*);
- textlen += strlen(atts[i]) + 1;
+ if ((i & 1) == 0)
+ textlen += strlen(skip_namespace(atts[i])) + 1;
+ else
+ textlen += strlen(atts[i]) + 1;
}
item = xps_alloc(ctx, sizeof(xps_item_t) + attslen + namelen + textlen);
@@ -94,7 +105,10 @@
for (i = 0; atts[i]; i++)
{
item->atts[i] = p;
- strcpy(item->atts[i], atts[i]);
+ if ((i & 1) == 0)
+ strcpy(item->atts[i], skip_namespace(atts[i]));
+ else
+ strcpy(item->atts[i], atts[i]);
p += strlen(p) + 1;
}
More information about the gs-cvs
mailing list