Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiles #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions NDHpple/NDHpple/NDHppleElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ class NDHppleElement {

var description: String { return self.node.description }

var hasChildren: Bool { return self[NDHppleNodeKey.Children.toRaw()] as? Int != nil }
var hasChildren: Bool { return self[NDHppleNodeKey.Children.rawValue] as? Int != nil }

var isTextNode: Bool { return self.tagName? == "text" && self.content != nil }

var raw: String? { return self["raw"] as? String }

var content: String? { return self[NDHppleNodeKey.Content.toRaw()] as? String }
var content: String? { return self[NDHppleNodeKey.Content.rawValue] as? String }

var tagName: String? { return self[NDHppleNodeKey.Name.toRaw()] as? String }
var tagName: String? { return self[NDHppleNodeKey.Name.rawValue] as? String }

var children: Array<NDHppleElement>? {

let children = self[NDHppleNodeKey.Children.toRaw()] as? Array<Dictionary<String, AnyObject>>
let children = self[NDHppleNodeKey.Children.rawValue] as? Array<Dictionary<String, AnyObject>>
return children?.map{ NDHppleElement(node: $0, parent: self) }
}

Expand All @@ -75,12 +75,12 @@ class NDHppleElement {
var attributes: Dictionary<String, AnyObject> {

var translatedAttribtues = Dictionary<String, AnyObject>()
for attributeDict in self[NDHppleNodeKey.AttributeArray.toRaw()] as Array<Dictionary<String, AnyObject>> {
for attributeDict in self[NDHppleNodeKey.AttributeArray.rawValue] as Array<Dictionary<String, AnyObject>> {

if attributeDict[NDHppleNodeKey.Content.toRaw()] != nil && attributeDict[NDHppleNodeKey.AttributeName.toRaw()] != nil {
if attributeDict[NDHppleNodeKey.Content.rawValue] != nil && attributeDict[NDHppleNodeKey.AttributeName.rawValue] != nil {

let value : AnyObject = attributeDict[NDHppleNodeKey.Content.toRaw()]!
let key : AnyObject = attributeDict[NDHppleNodeKey.AttributeName.toRaw()]!
let value : AnyObject = attributeDict[NDHppleNodeKey.Content.rawValue]!
let key : AnyObject = attributeDict[NDHppleNodeKey.AttributeName.rawValue]!

translatedAttribtues.updateValue(value, forKey: key as String)
}
Expand Down
18 changes: 9 additions & 9 deletions NDHpple/NDHpple/XPathQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ func createNode(currentNode: xmlNodePtr, inout parentDictionary: Dictionary<Stri
if currentNode.memory.name != nil {

let name = String.fromCString(UnsafePointer<CChar>(currentNode.memory.name))
resultForNode.updateValue(name!, forKey: NDHppleNodeKey.Name.toRaw())
resultForNode.updateValue(name!, forKey: NDHppleNodeKey.Name.rawValue)
}

if currentNode.memory.content != nil {

let content = String.fromCString(UnsafePointer<CChar>(currentNode.memory.content))
if resultForNode[NDHppleNodeKey.Name.toRaw()] as AnyObject? as? String == "text" {
if resultForNode[NDHppleNodeKey.Name.rawValue] as AnyObject? as? String == "text" {

if parentContent {

parentDictionary.updateValue(content!, forKey: NDHppleNodeKey.Content.toRaw())
parentDictionary.updateValue(content!, forKey: NDHppleNodeKey.Content.rawValue)
return nil
}

resultForNode.updateValue(content!, forKey: NDHppleNodeKey.Content.toRaw())
resultForNode.updateValue(content!, forKey: NDHppleNodeKey.Content.rawValue)
return resultForNode
} else {

resultForNode.updateValue(content!, forKey: NDHppleNodeKey.Content.toRaw())
resultForNode.updateValue(content!, forKey: NDHppleNodeKey.Content.rawValue)
}
}

Expand All @@ -48,14 +48,14 @@ func createNode(currentNode: xmlNodePtr, inout parentDictionary: Dictionary<Stri
let attributeName = attribute.memory.name
if attributeName != nil {

attributeDictionary.updateValue(String.fromCString(UnsafePointer<CChar>(attributeName))!, forKey: NDHppleNodeKey.AttributeName.toRaw())
attributeDictionary.updateValue(String.fromCString(UnsafePointer<CChar>(attributeName))!, forKey: NDHppleNodeKey.AttributeName.rawValue)
}

if attribute.memory.children != nil {

if let childDictionary = createNode(attribute.memory.children, &attributeDictionary, true) {

attributeDictionary.updateValue(childDictionary, forKey: NDHppleNodeKey.AttributeContent.toRaw())
attributeDictionary.updateValue(childDictionary, forKey: NDHppleNodeKey.AttributeContent.rawValue)
}
}

Expand All @@ -69,7 +69,7 @@ func createNode(currentNode: xmlNodePtr, inout parentDictionary: Dictionary<Stri

if attributeArray.count > 0 {

resultForNode.updateValue(attributeArray, forKey: NDHppleNodeKey.AttributeArray.toRaw())
resultForNode.updateValue(attributeArray, forKey: NDHppleNodeKey.AttributeArray.rawValue)
}
}

Expand All @@ -90,7 +90,7 @@ func createNode(currentNode: xmlNodePtr, inout parentDictionary: Dictionary<Stri

if childContentArray.count > 0 {

resultForNode.updateValue(childContentArray, forKey: NDHppleNodeKey.Children.toRaw())
resultForNode.updateValue(childContentArray, forKey: NDHppleNodeKey.Children.rawValue)
}
}

Expand Down