Skip to content

Commit

Permalink
[Issue #14] Renaming parameter identifiers from namespace to ns
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed May 29, 2014
1 parent cfbc461 commit 62c111d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions Ono/ONOXMLDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@
Returns the value for an attribute in a particular namespace.
@param attribute The attribute name.
@param namespace The attribute namespace.
@param ns The attribute namespace.
@return The associated value.
*/
- (id)valueForAttribute:(NSString *)attribute
inNamespace:(NSString *)namespace;
inNamespace:(NSString *)ns;

///----------------------------------------------------
/// @name Accessing Parent, Child, and Sibling Elements
Expand Down Expand Up @@ -307,12 +307,12 @@
Returns the first child element with a tag in a particular namespace, or `nil` if no such element exists.
@param tag The tag name.
@param namespace The namespace.
@param ns The namespace.
@return The child element.
*/
- (ONOXMLElement *)firstChildWithTag:(NSString *)tag
inNamespace:(NSString *)namespace;
inNamespace:(NSString *)ns;

/**
Returns all children elements with the specified tag.
Expand All @@ -327,12 +327,12 @@
Returns all children elements with the specified tag.
@param tag The tag name.
@param namespace The namepsace.
@param ns The namepsace.
@return The children elements.
*/
- (NSArray *)childrenWithTag:(NSString *)tag
inNamespace:(NSString *)namespace;
inNamespace:(NSString *)ns;

///------------------------
/// @name Accessing Content
Expand Down
16 changes: 8 additions & 8 deletions Ono/ONOXMLDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@
return [mutableXPathExpressions componentsJoinedByString:@" | "];
}

static BOOL ONOXMLNodeMatchesTagInNamespace(xmlNodePtr node, NSString *tag, NSString *namespace) {
static BOOL ONOXMLNodeMatchesTagInNamespace(xmlNodePtr node, NSString *tag, NSString *ns) {
BOOL matchingTag = !tag || [[NSString stringWithUTF8String:(const char *)node->name] compare:tag options:NSCaseInsensitiveSearch] == NSOrderedSame;

BOOL matchingNamespace = !namespace ? YES : (((node->ns != NULL) && (node->ns->prefix != NULL)) ? [[NSString stringWithUTF8String:(const char *)node->ns->prefix] compare:namespace options:NSCaseInsensitiveSearch] == NSOrderedSame : NO);
BOOL matchingNamespace = !ns ? YES : (((node->ns != NULL) && (node->ns->prefix != NULL)) ? [[NSString stringWithUTF8String:(const char *)node->ns->prefix] compare:ns options:NSCaseInsensitiveSearch] == NSOrderedSame : NO);

return matchingTag && matchingNamespace;
}
Expand Down Expand Up @@ -486,10 +486,10 @@ - (id)valueForAttribute:(NSString *)attribute {
}

- (id)valueForAttribute:(NSString *)attribute
inNamespace:(NSString *)namespace
inNamespace:(NSString *)ns
{
id value = nil;
const unsigned char *xmlValue = xmlGetNsProp(self.xmlNode, (const xmlChar *)[attribute cStringUsingEncoding:NSUTF8StringEncoding], (const xmlChar *)[namespace cStringUsingEncoding:NSUTF8StringEncoding]);
const unsigned char *xmlValue = xmlGetNsProp(self.xmlNode, (const xmlChar *)[attribute cStringUsingEncoding:NSUTF8StringEncoding], (const xmlChar *)[ns cStringUsingEncoding:NSUTF8StringEncoding]);
if (xmlValue) {
value = [NSString stringWithUTF8String:(const char *)xmlValue];
xmlFree((void *)xmlValue);
Expand Down Expand Up @@ -517,10 +517,10 @@ - (ONOXMLElement *)firstChildWithTag:(NSString *)tag {
}

- (ONOXMLElement *)firstChildWithTag:(NSString *)tag
inNamespace:(NSString *)namespace
inNamespace:(NSString *)ns
{
NSArray *children = [self childrenAtIndexes:[self indexesOfChildrenPassingTest:^BOOL(xmlNodePtr node, BOOL *stop) {
*stop = ONOXMLNodeMatchesTagInNamespace(node, tag, namespace);
*stop = ONOXMLNodeMatchesTagInNamespace(node, tag, ns);
return *stop;
}]];

Expand All @@ -536,11 +536,11 @@ - (NSArray *)childrenWithTag:(NSString *)tag {
}

- (NSArray *)childrenWithTag:(NSString *)tag
inNamespace:(NSString *)namespace
inNamespace:(NSString *)ns
{

return [self childrenAtIndexes:[self indexesOfChildrenPassingTest:^BOOL(xmlNodePtr node, BOOL *stop) {
return ONOXMLNodeMatchesTagInNamespace(node, tag, namespace);
return ONOXMLNodeMatchesTagInNamespace(node, tag, ns);
}]];
}

Expand Down

0 comments on commit 62c111d

Please sign in to comment.