diff --git a/cmXml.c b/cmXml.c index 6d465bc..2fcf15c 100644 --- a/cmXml.c +++ b/cmXml.c @@ -1021,6 +1021,52 @@ unsigned _cmXmlLabelCount( const cmChar_t* firstLabel, va_list vl ) return n; } + +const cmXmlNode_t* _cmXmlNodeHasChildR( const cmXmlNode_t* np, unsigned argIdx, const cmChar_t**argV, unsigned argN, const cmChar_t* attrLabel, const cmChar_t* valueStr) +{ + if( argIdx == argN ) + return NULL; + + + const cmXmlNode_t* cnp = np->children; + for(; cnp!=NULL; cnp=cnp->sibling) + if( cmTextCmp(cnp->label,argV[argIdx]) == 0 ) + { + const cmXmlNode_t* tnp = _cmXmlNodeHasChildR(cnp,argIdx+1,argV,argN,attrLabel,valueStr); + + if( attrLabel != NULL ) + { + const cmXmlAttr_t* a; + if((a = cmXmlFindAttrib(np,attrLabel)) == NULL ) + continue; + + + if( valueStr != NULL ) + { + if( cmTextCmp(a->value,valueStr) != 0 ) + continue; + } + } + + if( tnp != NULL ) + return tnp; + } + + return NULL; +} + +const cmXmlNode_t* _cmXmlNodeHasChildV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl, unsigned argN, const cmChar_t* attrLabel, const cmChar_t* valueStr ) +{ + unsigned i; + const cmChar_t* argV[ argN+1 ]; + argV[0] = label; + for(i=1; i n-1 ); // an attribute label must be given. + + if( argN <= n-1 ) + goto errLabel; + + argN -= n; + + + // advance vl0 to the attribute label + for(i=1; i