Home
The Toolkit for Online Communities
17308 Community Members, 0 members online, 2201 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Development : ANN: IMS-LD beta released : One Message

Forum OpenACS Development: question about tDOM and namespaces (Re: ANN: IMS-LD beta released )

When you parse the imsmanifest file, you assume that the http://www.imsglobal.org/xsd/imscp_v1p1 namespace is mapped to the prefix imscp. But a imsmanifest file could map the namespace to any other prefix and still be valid according to the specification. Isn't is possible to tell the tdom parser to look for the namespace according to the URI and not the prefix. This would make the code also more readable, because you would not have to look for unprefixed and prefixed nodes?
Regards,
To answer my own question. According to http://www.panoptic.com/wiki/aolserver/TDOM, it is possible to make XPath queries independent from the prefix in the source document by adding a namespace declaration node to the root with a prefix of your own choosing.
This could mean, that after parsing the manifest you could call
$manifest setAttributeNS "" xmlns:imscp "http://www.imsglobal.org/xsd/imscp_v1p1"

Whereever in the code where you have constructs like

set organizations [$manifest child all imscp:organizations]
if { ![llength $organizations] } {
set organizations [$manifest child all organizations]
}

you could more simply write

set organizations [$manifest selectNodes imscp:organizations]

What do you think?

Regards,

Thanks for your help.

Just one question. That would affect all the child nodes, right?, what about the imsld specific nodes?

Yes, my idea is whenever you have to retrieve child nodes to use the selectNodes function, because thus you query for the actual namespace and not the prefix, whereas the child function seems to retrieve nodes only based on the prefix.

Sorry, that I forgot to add that the same would be necessary for all namespaces used in the manifest.