Re: Issue with displaying URI prefixes on child elements using NSXML
On 12/06/2008, at 6:54 PM, Nathan Kinsinger wrote: I'm curious about what using elementWithName:URI: is supposed to do when you don't pass a qualified name in, or rather, why have it at all? The URI seems to be redundant if you are already passing the qualified name in. Just as a test (from the OP's code) NSXMLElement *root = [NSXMLNode elementWithName:@root]; [root addNamespace:[NSXMLNode namespaceWithName:@a stringValue:@http://www.tempurl.com ]]; NSXMLElement *child = [NSXMLNode elementWithName:@child URI:@http://www.tempurl.com ]; [child addChild:[NSXMLNode textWithStringValue:@myText]]; [root addChild:child]; NSXMLElement *child2 = [NSXMLNode elementWithName:@child]; [child2 addChild:[NSXMLNode textWithStringValue:@myOtherText]]; [root addChild:child2]; NSXMLElement *child3 = [NSXMLNode elementWithName:@a:child]; [child3 addChild:[NSXMLNode textWithStringValue:@something completely different]]; [root addChild:child3]; NSLog(@a:child = %@, [root elementsForName:@a:child]); gives the result: a:child = ( childmyText/child, a:childsomething completely different/a:child ) So the NSXMLElement has an internal state (that the first child is in the a namespace) that is not in it's XML representation? If you were to save it and then read it back in you would lose that information. From the few bits of XML I've dealt with I never needed to deal with namespaces, I'm just curious about this. I think it’s this way because you don’t necessarily need to include the prefix within the mark-up (the namespace can be dictated by the default) so there needs to be a way of indicating whether or not a prefix is included. You’re correct that you’d lose that information if you were to save and then load it back in (so long as there’s no default namespace). There’s the -canonicalXMLStringPreservingComments: method that I believe will ensure that all names have prefixes. - Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Issue with displaying URI prefixes on child elements using NSXML
On 11/06/2008, at 3:19 PM, Lawrence Johnston wrote: Hey everybody, I've got an issue that I can't figure out. If I'm using this code: NSString *XMLForDisplay { NSXMLElement *root = [NSXMLNode elementWithName:@root]; [root addNamespace:[NSXMLNode namespaceWithName:@a stringValue:@http://www.tempurl.com ]]; NSXMLElement *child = [NSXMLNode elementWithName:@child URI:@http://www.tempurl.com ]; [child addChild:[NSXMLNode textWithStringValue:@myText]]; [root addChild:child]; return [root XMLStringWithOptions:NSXMLNodePrettyPrint]; } I believe it should be outputting this text: root xmlns:a=http://www.tempurl.com; a:childmyText/a:child /root However, instead it outputs this text (note the lack of prefix on the child): root xmlns:a=http://www.tempurl.com; childmyText/child /root This is an issue, because I need that a: prefix. The documentation for elementWithName:URI: states it's equivalent to URI:name/URI:name, which is exactly what I want, except that I can't get it to display that way. Thanks for your time. The documentation says that you need to pass the qualified name in. So you need to do: NSXMLElement *child = [NSXMLNode elementWithName:@a:child URI:@http://www.tempurl.com ]; You can look-up the prefix using NSXMLElement’s resolvePrefixForNamespaceURI: method although you probably don’t need to do that. - Chris smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Issue with displaying URI prefixes on child elements using NSXML
It all makes sense now. Thanks. On Jun 11, 2008, at 11:48 PM, Chris Suter wrote: On 11/06/2008, at 3:19 PM, Lawrence Johnston wrote: Hey everybody, I've got an issue that I can't figure out. If I'm using this code: NSString *XMLForDisplay { NSXMLElement *root = [NSXMLNode elementWithName:@root]; [root addNamespace:[NSXMLNode namespaceWithName:@a stringValue:@http://www.tempurl.com ]]; NSXMLElement *child = [NSXMLNode elementWithName:@child URI:@http://www.tempurl.com ]; [child addChild:[NSXMLNode textWithStringValue:@myText]]; [root addChild:child]; return [root XMLStringWithOptions:NSXMLNodePrettyPrint]; } I believe it should be outputting this text: root xmlns:a=http://www.tempurl.com; a:childmyText/a:child /root However, instead it outputs this text (note the lack of prefix on the child): root xmlns:a=http://www.tempurl.com; childmyText/child /root This is an issue, because I need that a: prefix. The documentation for elementWithName:URI: states it's equivalent to URI:name/URI:name, which is exactly what I want, except that I can't get it to display that way. Thanks for your time. The documentation says that you need to pass the qualified name in. So you need to do: NSXMLElement *child = [NSXMLNode elementWithName:@a:child URI:@http://www.tempurl.com ]; You can look-up the prefix using NSXMLElement’s resolvePrefixForNamespaceURI: method although you probably don’t need to do that. - Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Issue with displaying URI prefixes on child elements using NSXML
On Jun 12, 2008, at 12:48 AM, Chris Suter wrote: The documentation says that you need to pass the qualified name in. So you need to do: NSXMLElement *child = [NSXMLNode elementWithName:@a:child URI:@http://www.tempurl.com ]; You can look-up the prefix using NSXMLElement’s resolvePrefixForNamespaceURI: method although you probably don’t need to do that. - Chris I'm curious about what using elementWithName:URI: is supposed to do when you don't pass a qualified name in, or rather, why have it at all? The URI seems to be redundant if you are already passing the qualified name in. Just as a test (from the OP's code) NSXMLElement *root = [NSXMLNode elementWithName:@root]; [root addNamespace:[NSXMLNode namespaceWithName:@a stringValue:@http://www.tempurl.com ]]; NSXMLElement *child = [NSXMLNode elementWithName:@child URI:@http://www.tempurl.com ]; [child addChild:[NSXMLNode textWithStringValue:@myText]]; [root addChild:child]; NSXMLElement *child2 = [NSXMLNode elementWithName:@child]; [child2 addChild:[NSXMLNode textWithStringValue:@myOtherText]]; [root addChild:child2]; NSXMLElement *child3 = [NSXMLNode elementWithName:@a:child]; [child3 addChild:[NSXMLNode textWithStringValue:@something completely different]]; [root addChild:child3]; NSLog(@a:child = %@, [root elementsForName:@a:child]); gives the result: a:child = ( childmyText/child, a:childsomething completely different/a:child ) So the NSXMLElement has an internal state (that the first child is in the a namespace) that is not in it's XML representation? If you were to save it and then read it back in you would lose that information. From the few bits of XML I've dealt with I never needed to deal with namespaces, I'm just curious about this. --Nathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Issue with displaying URI prefixes on child elements using NSXML
Hey everybody, I've got an issue that I can't figure out. If I'm using this code: NSString *XMLForDisplay { NSXMLElement *root = [NSXMLNode elementWithName:@root]; [root addNamespace:[NSXMLNode namespaceWithName:@a stringValue:@http://www.tempurl.com ]]; NSXMLElement *child = [NSXMLNode elementWithName:@child URI:@http://www.tempurl.com ]; [child addChild:[NSXMLNode textWithStringValue:@myText]]; [root addChild:child]; return [root XMLStringWithOptions:NSXMLNodePrettyPrint]; } I believe it should be outputting this text: root xmlns:a=http://www.tempurl.com; a:childmyText/a:child /root However, instead it outputs this text (note the lack of prefix on the child): root xmlns:a=http://www.tempurl.com; childmyText/child /root This is an issue, because I need that a: prefix. The documentation for elementWithName:URI: states it's equivalent to URI:name/URI:name, which is exactly what I want, except that I can't get it to display that way. Thanks for your time. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]