Lines Matching refs:ctx
86 xmlC14NCtxPtr ctx);
94 static int xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur);
95 static int xmlC14NProcessNodeList(xmlC14NCtxPtr ctx, xmlNodePtr cur);
115 #define xmlC14NIsVisible( ctx, node, parent ) \
116 (((ctx)->is_visible_callback != NULL) ? \
117 (ctx)->is_visible_callback((ctx)->user_data, \
398 * @ctx: the C14N context
440 xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx) {
466 return(xmlC14NIsVisible(ctx, ns1, cur->nodeTab[i]));
527 * @ctx: the C14N context
534 xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx)
537 if ((ns == NULL) || (ctx == NULL)) {
543 xmlOutputBufferWriteString(ctx->buf, " xmlns:");
544 xmlOutputBufferWriteString(ctx->buf, (const char *) ns->prefix);
545 xmlOutputBufferWriteString(ctx->buf, "=\"");
547 xmlOutputBufferWriteString(ctx->buf, " xmlns=\"");
550 xmlOutputBufferWriteString(ctx->buf, (const char *) ns->href);
552 xmlOutputBufferWriteString(ctx->buf, "\"");
558 * @ctx: the C14N context
596 xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
604 if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
623 if((tmp == ns) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) {
624 already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns);
626 xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
651 if(!xmlC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default)) {
652 xmlC14NPrintNamespaces(&ns_default, ctx);
660 xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
672 * @ctx: the C14N context
701 xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
711 if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
716 if(!ctx->exclusive) {
736 if(ctx->inclusive_ns_prefixes != NULL) {
740 for (i = 0; ctx->inclusive_ns_prefixes[i] != NULL; ++i) {
741 prefix = ctx->inclusive_ns_prefixes[i];
752 if((ns != NULL) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) {
753 already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns);
755 xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
775 if(visible && xmlC14NIsVisible(ctx, ns, cur)) {
776 if(!xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, ns, ctx)) {
781 xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
796 if((attr->ns != NULL) && !xmlC14NIsXmlNs(attr->ns) && xmlC14NIsVisible(ctx, attr, cur)) {
797 already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, attr->ns, ctx);
798 xmlC14NVisibleNsStackAdd(ctx->ns_rendered, attr->ns, cur);
819 already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default, ctx);
821 xmlC14NPrintNamespaces(&ns_default, ctx);
827 if(!xmlC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default)) {
828 xmlC14NPrintNamespaces(&ns_default, ctx);
837 xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
899 * @ctx: the C14N context
909 xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
914 if ((attr == NULL) || (ctx == NULL)) {
919 xmlOutputBufferWriteString(ctx->buf, " ");
921 xmlOutputBufferWriteString(ctx->buf,
923 xmlOutputBufferWriteString(ctx->buf, ":");
925 xmlOutputBufferWriteString(ctx->buf, (const char *) attr->name);
926 xmlOutputBufferWriteString(ctx->buf, "=\"");
934 xmlOutputBufferWriteString(ctx->buf, (const char *) buffer);
941 xmlOutputBufferWriteString(ctx->buf, "\"");
947 * @ctx: the C14N context
978 xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
983 if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
1003 if (xmlC14NIsVisible(ctx, attr, cur)) {
1013 if (parent_visible && (!ctx->exclusive) && (cur->parent != NULL)
1014 && (!xmlC14NIsVisible(ctx, cur->parent, cur->parent->parent))) {
1038 xmlListWalk(list, (xmlListWalker) xmlC14NPrintAttrs, (const void *) ctx);
1049 * @ctx: the C14N context
1057 xmlC14NCheckForRelativeNamespaces(xmlC14NCtxPtr ctx, xmlNodePtr cur)
1061 if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
1097 * @ctx: the pointer to C14N context object
1117 xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
1123 if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
1133 if (xmlC14NCheckForRelativeNamespaces(ctx, cur) < 0) {
1143 xmlC14NVisibleNsStackSave(ctx->ns_rendered, &state);
1146 if (ctx->parent_is_doc) {
1148 parent_is_doc = ctx->parent_is_doc;
1149 ctx->parent_is_doc = 0;
1150 ctx->pos = XMLC14N_INSIDE_DOCUMENT_ELEMENT;
1152 xmlOutputBufferWriteString(ctx->buf, "<");
1155 xmlOutputBufferWriteString(ctx->buf,
1157 xmlOutputBufferWriteString(ctx->buf, ":");
1159 xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name);
1162 if (!ctx->exclusive) {
1163 ret = xmlC14NProcessNamespacesAxis(ctx, cur, visible);
1165 ret = xmlExcC14NProcessNamespacesAxis(ctx, cur, visible);
1173 xmlC14NVisibleNsStackShift(ctx->ns_rendered);
1176 ret = xmlC14NProcessAttrsAxis(ctx, cur, visible);
1183 xmlOutputBufferWriteString(ctx->buf, ">");
1186 ret = xmlC14NProcessNodeList(ctx, cur->children);
1193 xmlOutputBufferWriteString(ctx->buf, "</");
1195 xmlOutputBufferWriteString(ctx->buf,
1197 xmlOutputBufferWriteString(ctx->buf, ":");
1199 xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name);
1200 xmlOutputBufferWriteString(ctx->buf, ">");
1203 ctx->parent_is_doc = parent_is_doc;
1204 ctx->pos = XMLC14N_AFTER_DOCUMENT_ELEMENT;
1211 xmlC14NVisibleNsStackRestore(ctx->ns_rendered, &state);
1217 * @ctx: the pointer to C14N context object
1225 xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
1230 if ((ctx == NULL) || (cur == NULL)) {
1235 visible = xmlC14NIsVisible(ctx, cur, cur->parent);
1238 ret = xmlC14NProcessElementNode(ctx, cur, visible);
1256 xmlOutputBufferWriteString(ctx->buf,
1279 if (ctx->pos == XMLC14N_AFTER_DOCUMENT_ELEMENT) {
1280 xmlOutputBufferWriteString(ctx->buf, "\x0A<?");
1282 xmlOutputBufferWriteString(ctx->buf, "<?");
1285 xmlOutputBufferWriteString(ctx->buf,
1290 xmlOutputBufferWriteString(ctx->buf, " ");
1295 xmlOutputBufferWriteString(ctx->buf,
1304 if (ctx->pos == XMLC14N_BEFORE_DOCUMENT_ELEMENT) {
1305 xmlOutputBufferWriteString(ctx->buf, "?>\x0A");
1307 xmlOutputBufferWriteString(ctx->buf, "?>");
1327 if (visible && ctx->with_comments) {
1328 if (ctx->pos == XMLC14N_AFTER_DOCUMENT_ELEMENT) {
1329 xmlOutputBufferWriteString(ctx->buf, "\x0A<!--");
1331 xmlOutputBufferWriteString(ctx->buf, "<!--");
1340 xmlOutputBufferWriteString(ctx->buf,
1349 if (ctx->pos == XMLC14N_BEFORE_DOCUMENT_ELEMENT) {
1350 xmlOutputBufferWriteString(ctx->buf, "-->\x0A");
1352 xmlOutputBufferWriteString(ctx->buf, "-->");
1365 ctx->pos = XMLC14N_BEFORE_DOCUMENT_ELEMENT;
1366 ctx->parent_is_doc = 1;
1367 ret = xmlC14NProcessNodeList(ctx, cur->children);
1408 * @ctx: the pointer to C14N context object
1416 xmlC14NProcessNodeList(xmlC14NCtxPtr ctx, xmlNodePtr cur)
1420 if (ctx == NULL) {
1426 ret = xmlC14NProcessNode(ctx, cur);
1434 * @ctx: the pointer to C14N context object
1440 xmlC14NFreeCtx(xmlC14NCtxPtr ctx)
1442 if (ctx == NULL) {
1447 if (ctx->ns_rendered != NULL) {
1448 xmlC14NVisibleNsStackDestroy(ctx->ns_rendered);
1450 xmlFree(ctx);
1479 xmlC14NCtxPtr ctx = NULL;
1490 xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8,
1499 xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8,
1507 ctx = (xmlC14NCtxPtr) xmlMalloc(sizeof(xmlC14NCtx));
1508 if (ctx == NULL) {
1512 memset(ctx, 0, sizeof(xmlC14NCtx));
1517 ctx->doc = doc;
1518 ctx->with_comments = with_comments;
1519 ctx->is_visible_callback = is_visible_callback;
1520 ctx->user_data = user_data;
1521 ctx->buf = buf;
1522 ctx->parent_is_doc = 1;
1523 ctx->pos = XMLC14N_BEFORE_DOCUMENT_ELEMENT;
1524 ctx->ns_rendered = xmlC14NVisibleNsStackCreate();
1526 if(ctx->ns_rendered == NULL) {
1527 xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_CREATE_STACK,
1529 xmlC14NFreeCtx(ctx);
1538 ctx->exclusive = 1;
1539 ctx->inclusive_ns_prefixes = inclusive_ns_prefixes;
1541 return (ctx);
1573 xmlC14NCtxPtr ctx;
1590 ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data,
1593 if (ctx == NULL) {
1610 ret = xmlC14NProcessNodeList(ctx, doc->children);
1613 xmlC14NFreeCtx(ctx);
1624 xmlC14NFreeCtx(ctx);
1631 xmlC14NFreeCtx(ctx);