Resolve the specified prefix to a namespace. The I{nsprefixes} is searched. If not found, it walks up the tree until either resolved or the top of the tree is reached. Searching up the tree provides for inherited mappings. @param prefix: A namespace prefix
(self, prefix, default=Namespace.default)
| 503 | return detached |
| 504 | |
| 505 | def resolvePrefix(self, prefix, default=Namespace.default): |
| 506 | """ |
| 507 | Resolve the specified prefix to a namespace. The I{nsprefixes} is |
| 508 | searched. If not found, it walks up the tree until either resolved or |
| 509 | the top of the tree is reached. Searching up the tree provides for |
| 510 | inherited mappings. |
| 511 | @param prefix: A namespace prefix to resolve. |
| 512 | @type prefix: basestring |
| 513 | @param default: An optional value to be returned when the prefix |
| 514 | cannot be resolved. |
| 515 | @type default: (I{prefix},I{URI}) |
| 516 | @return: The namespace that is mapped to I{prefix} in this context. |
| 517 | @rtype: (I{prefix},I{URI}) |
| 518 | """ |
| 519 | n = self |
| 520 | while n is not None: |
| 521 | if prefix in n.nsprefixes: |
| 522 | return (prefix, n.nsprefixes[prefix]) |
| 523 | if prefix in self.specialprefixes: |
| 524 | return (prefix, self.specialprefixes[prefix]) |
| 525 | n = n.parent |
| 526 | return default |
| 527 | |
| 528 | def addPrefix(self, p, u): |
| 529 | """ |
no outgoing calls
no test coverage detected