📄 main.c
字号:
if ( ctxt->node->doc == NULL ) { /* if one XPaths a node from a fragment, libxml2 will refuse the lookup. this is not very usefull for XML scripters. thus we need to create a temporary document to make libxml2 do it's job correctly. */ tdoc = xmlNewDoc( NULL ); /* find refnode's root node */ while ( froot != NULL ) { if ( froot->parent == NULL ) { break; } froot = froot->parent; } xmlAddChild((xmlNodePtr)tdoc, froot); ctxt->node->doc = tdoc; } res = xmlXPathCompiledEval(comp, ctxt); xmlXPathFreeCompExpr(comp); if ( tdoc != NULL ) { /* after looking through a fragment, we need to drop the fake document again */ xmlSetTreeDoc(froot,NULL); froot->doc = NULL; tdoc->children = NULL; tdoc->last = NULL; froot->parent = NULL; ctxt->node->doc = NULL; xmlFreeDoc( tdoc ); } } if (res && res->type == XPATH_NODESET) return res->nodesetval; else return NULL;}/* definition of GPAC groups of SVG attributes */void setAttributeType(SVGGenAttribute *att) { if (!att->svg_type) { /* if the type is not given in the RNG, we explicitely set it */ if (!strcmp(att->svg_name, "textContent")) { strcpy(att->impl_type, "SVG_TextContent"); } else if (!strcmp(att->svg_name, "class")) { strcpy(att->implementation_name, "_class"); strcpy(att->impl_type, "SVG_String"); } else if (!strcmp(att->svg_name, "visibility")) { strcpy(att->impl_type, "SVG_Visibility"); } else if (!strcmp(att->svg_name, "display")) { strcpy(att->impl_type, "SVG_Display"); } else if (!strcmp(att->svg_name, "stroke-linecap")) { strcpy(att->impl_type, "SVG_StrokeLineCap"); } else if (!strcmp(att->svg_name, "stroke-dasharray")) { strcpy(att->impl_type, "SVG_StrokeDashArray"); } else if (!strcmp(att->svg_name, "stroke-linejoin")) { strcpy(att->impl_type, "SVG_StrokeLineJoin"); } else if (!strcmp(att->svg_name, "font-style")) { strcpy(att->impl_type, "SVG_FontStyle"); } else if (!strcmp(att->svg_name, "font-weight")) { strcpy(att->impl_type, "SVG_FontWeight"); } else if (!strcmp(att->svg_name, "text-anchor")) { strcpy(att->impl_type, "SVG_TextAnchor"); } else if (!strcmp(att->svg_name, "fill")) { strcpy(att->impl_type, "SMIL_Fill"); } else if (!strcmp(att->svg_name, "fill-rule")) { strcpy(att->impl_type, "SVG_FillRule"); } else if (!strcmp(att->svg_name, "font-family")) { strcpy(att->impl_type, "SVG_FontFamily"); } else if (!strcmp(att->svg_name, "calcMode")) { strcpy(att->impl_type, "SMIL_CalcMode"); } else if (!strcmp(att->svg_name, "values")) { strcpy(att->impl_type, "SMIL_AnimateValues"); } else if (!strcmp(att->svg_name, "keyTimes")) { strcpy(att->impl_type, "SMIL_KeyTimes"); } else if (!strcmp(att->svg_name, "keySplines")) { strcpy(att->impl_type, "SMIL_KeySplines"); } else if (!strcmp(att->svg_name, "keyPoints")) { strcpy(att->impl_type, "SMIL_KeyPoints"); } else if (!strcmp(att->svg_name, "from") || !strcmp(att->svg_name, "to") || !strcmp(att->svg_name, "by")) { strcpy(att->impl_type, "SMIL_AnimateValue"); } else if (!strcmp(att->svg_name, "additive")) { strcpy(att->impl_type, "SMIL_Additive"); } else if (!strcmp(att->svg_name, "accumulate")) { strcpy(att->impl_type, "SMIL_Accumulate"); } else if (!strcmp(att->svg_name, "begin") || !strcmp(att->svg_name, "end") ) { strcpy(att->impl_type, "SMIL_Times"); } else if (!strcmp(att->svg_name, "clipBegin") || !strcmp(att->svg_name, "clipEnd") ) { strcpy(att->impl_type, "SVG_Clock"); } else if (!strcmp(att->svg_name, "min") || !strcmp(att->svg_name, "max") || !strcmp(att->svg_name, "dur") || !strcmp(att->svg_name, "repeatDur") ) { strcpy(att->impl_type, "SMIL_Duration"); } else if (!strcmp(att->svg_name, "repeat")) { strcpy(att->impl_type, "SMIL_Repeat"); } else if (!strcmp(att->svg_name, "restart")) { strcpy(att->impl_type, "SMIL_Restart"); } else if (!strcmp(att->svg_name, "repeatCount")) { strcpy(att->impl_type, "SMIL_RepeatCount"); } else if (!strcmp(att->svg_name, "attributeName")) { strcpy(att->impl_type, "SMIL_AttributeName"); } else if (!strcmp(att->svg_name, "type")) { strcpy(att->impl_type, "SVG_TransformType"); } else if (!strcmp(att->svg_name, "font-size")) { strcpy(att->impl_type, "SVG_FontSize"); } else if (!strcmp(att->svg_name, "viewBox")) { strcpy(att->impl_type, "SVG_ViewBox"); } else if (!strcmp(att->svg_name, "preserveAspectRatio")) { strcpy(att->impl_type, "SVG_PreserveAspectRatio"); } else if (!strcmp(att->svg_name, "zoomAndPan")) { strcpy(att->impl_type, "SVG_ZoomAndPan"); } else if (!strcmp(att->svg_name, "path")) { strcpy(att->impl_type, "SVG_PathData"); } else if (!strcmp(att->svg_name, "image-rendering")) { strcpy(att->impl_type, "SVG_RenderingHint"); } else if (!strcmp(att->svg_name, "color-rendering")) { strcpy(att->impl_type, "SVG_RenderingHint"); } else if (!strcmp(att->svg_name, "text-rendering")) { strcpy(att->impl_type, "SVG_RenderingHint"); } else if (!strcmp(att->svg_name, "shape-rendering")) { strcpy(att->impl_type, "SVG_RenderingHint"); } else if (!strcmp(att->svg_name, "pointer-events")) { strcpy(att->impl_type, "SVG_PointerEvents"); } else if (!strcmp(att->svg_name, "vector-effect")) { strcpy(att->impl_type, "SVG_VectorEffect"); } else if (!strcmp(att->svg_name, "vector-effect")) { strcpy(att->impl_type, "SVG_VectorEffect"); } else if (!strcmp(att->svg_name, "display-align")) { strcpy(att->impl_type, "SVG_DisplayAlign"); } else if (!strcmp(att->svg_name, "text-align")) { strcpy(att->impl_type, "SVG_TextAlign"); } else if (!strcmp(att->svg_name, "propagate")) { strcpy(att->impl_type, "XMLEV_Propagate"); } else if (!strcmp(att->svg_name, "defaultAction")) { strcpy(att->impl_type, "XMLEV_DefaultAction"); } else if (!strcmp(att->svg_name, "phase")) { strcpy(att->impl_type, "XMLEV_Phase"); } else if (!strcmp(att->svg_name, "syncBehavior")) { strcpy(att->impl_type, "SMIL_SyncBehavior"); } else if (!strcmp(att->svg_name, "syncBehaviorDefault")) { strcpy(att->impl_type, "SMIL_SyncBehavior"); } else if (!strcmp(att->svg_name, "attributeType")) { strcpy(att->impl_type, "SMIL_AttributeType"); } else if (!strcmp(att->svg_name, "playbackOrder")) { strcpy(att->impl_type, "SVG_PlaybackOrder"); } else if (!strcmp(att->svg_name, "timelineBegin")) { strcpy(att->impl_type, "SVG_TimelineBegin"); } else if (!strcmp(att->svg_name, "xml:space")) { strcpy(att->impl_type, "XML_Space"); } else if (!strcmp(att->svg_name, "snapshotTime")) { strcpy(att->impl_type, "SVG_Clock"); } else if (!strcmp(att->svg_name, "version")) { strcpy(att->impl_type, "SVG_String"); } else if (!strcmp(att->svg_name, "gradientUnits")) { strcpy(att->impl_type, "SVG_GradientUnit"); } else if (!strcmp(att->svg_name, "baseProfile")) { strcpy(att->impl_type, "SVG_String"); } else if (!strcmp(att->svg_name, "focusHighlight")) { strcpy(att->impl_type, "SVG_FocusHighlight"); } else if (!strcmp(att->svg_name, "initialVisibility")) { strcpy(att->impl_type, "SVG_InitialVisibility"); } else if (!strcmp(att->svg_name, "overlay")) { strcpy(att->impl_type, "SVG_Overlay"); } else if (!strcmp(att->svg_name, "transformBehavior")) { strcpy(att->impl_type, "SVG_TransformBehavior"); } else if (!strcmp(att->svg_name, "rotate")) { strcpy(att->impl_type, "SVG_Rotate"); } else if (!strcmp(att->svg_name, "font-variant")) { strcpy(att->impl_type, "SVG_FontVariant"); } else if (!strcmp(att->svg_name, "lsr:enabled")) { strcpy(att->impl_type, "SVG_Boolean"); } else if (!strcmp(att->svg_name, "spreadMethod")) { strcpy(att->impl_type, "SVG_SpreadMethod"); } else if (!strcmp(att->svg_name, "gradientTransform")) { strcpy(att->impl_type, "SVG_Transform_Full"); } else if (!strcmp(att->svg_name, "editable")) { strcpy(att->impl_type, "SVG_Boolean"); } else if (!strcmp(att->svg_name, "choice")) { strcpy(att->impl_type, "LASeR_Choice"); } else if (!strcmp(att->svg_name, "size") || !strcmp(att->svg_name, "delta")) { strcpy(att->impl_type, "LASeR_Size"); } else if (!strcmp(att->svg_name, "syncReference")) { strcpy(att->impl_type, "XMLRI"); } else { /* For all other attributes, we use String as default type */ strcpy(att->impl_type, "SVG_String"); fprintf(stdout, "Warning: using type SVG_String for attribute %s.\n", att->svg_name); } } else { /* for some attributes, the type given in the RNG needs to be overriden */ if (!strcmp(att->svg_name, "color")) { strcpy(att->impl_type, "SVG_Paint"); } else if (!strcmp(att->svg_name, "viewport-fill")) { strcpy(att->impl_type, "SVG_Paint"); } else if (!strcmp(att->svg_name, "syncTolerance")) { strcpy(att->impl_type, "SMIL_SyncTolerance"); } else if (!strcmp(att->svg_name, "syncToleranceDefault")) { strcpy(att->impl_type, "SMIL_SyncTolerance"); } else if (!strcmp(att->svg_name, "transform")) { strcpy(att->impl_type, "SVG_Transform"); } else if (!strcmp(att->svg_name, "gradientTransform")) { strcpy(att->impl_type, "SVG_Transform"); } else if (!strcmp(att->svg_name, "focusable")) { strcpy(att->impl_type, "SVG_Focusable"); } else if (!strcmp(att->svg_name, "event") || !strcmp(att->svg_name, "ev:event")) { strcpy(att->impl_type, "XMLEV_Event"); } else if (!strcmp(att->svg_type, "IRI.datatype")) { strcpy(att->impl_type, "XMLRI"); } else if (!strcmp(att->svg_type, "IDREF.datatype")) { strcpy(att->impl_type, "XML_IDREF"); } else if (strstr(att->svg_type, "datatype")) { char *tmp; sprintf(att->impl_type, "SVG_%s", att->svg_type); tmp = att->impl_type; while ( (tmp = strstr(tmp, "-")) ) { *tmp='_'; tmp++; } tmp = att->impl_type; while ( (tmp = strstr(tmp, ".")) ) { *tmp='_'; tmp++; } tmp = att->impl_type;; if ( (tmp = strstr(tmp, "datatype")) ) { tmp--; *tmp = 0; } } }}void getAttributeType(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlNodePtr attributeNode, SVGGenAttribute *a) { xmlNodeSetPtr refNodes; xpathCtx->node = attributeNode; refNodes = findNodes(xpathCtx, ".//rng:ref"); if (refNodes->nodeNr == 0) { //a->svg_type = xmlStrdup("0_ref_type"); } else if (refNodes->nodeNr == 1) { xmlNodePtr ref = refNodes->nodeTab[0]; a->svg_type = xmlStrdup(xmlGetProp(ref, "name")); } else { //a->svg_type = xmlStrdup("N_ref_type"); }}void getRealAttributes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlNodePtr newCtxNode, GF_List *attributes){ xmlNodeSetPtr attributeNodes; int k; u32 j; xpathCtx->node = newCtxNode; attributeNodes = findNodes(xpathCtx, ".//rng:attribute"); for (k = 0; k < attributeNodes->nodeNr; k++) { Bool already_exists = 0; xmlNodePtr attributeNode = attributeNodes->nodeTab[k]; if (attributeNode->type == XML_ELEMENT_NODE) { SVGGenAttribute *a = NewSVGGenAttribute(); a->svg_name = xmlGetProp(attributeNode, "name"); a->optional = xmlStrEqual(attributeNode->parent->name, "optional"); svgNameToImplementationName(a->svg_name, a->implementation_name); getAttributeType(doc, xpathCtx, attributeNode, a); setAttributeType(a); for (j=0;j<gf_list_count(attributes); j++) { SVGGenAttribute *ta = gf_list_get(attributes, j); if (xmlStrEqual(ta->svg_name, a->svg_name)) { already_exists = 1; break; } } if (already_exists) { deleteSVGGenAttribute(&a); } else { //fprintf(stdout, "Adding attribute %s to element %s\n",a->svg_name, e->svg_name); gf_list_add(attributes, a); } } }}SVGGenAttrGrp *getOneGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlChar *name) { SVGGenAttrGrp *attgrp = NULL; xmlNodeSetPtr attrGrpDefNodes; xmlChar *expr; u32 j; int i, l; /* attributes group already resolved */ for (j = 0; j < gf_list_count(globalAttrGrp); j++) { SVGGenAttrGrp *attgrp = gf_list_get(globalAttrGrp, j); if (!strcmp(attgrp->name, name)) { return attgrp; } } /* new attributes group */ expr = xmlStrdup("//rng:define[@name=\""); expr = xmlStrcat(expr, name);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -