Search
3
votes
closed
GetMedia returns documentElement not firstChild (v4.5)

Description

In Umbraco v4.5, GetMedia returns the documentElement of the XML, where in previous versions (v4.0.x and lower) it returned the firstChild.

The biggest problem is that this breaks backwards compatibility when upgrading from v4.0.x (with 'UseLegacyXmlSchema' enabled).

In both versions, the XML returned from GetMedia look the same - however the XPathNodeIterator is positioned at different nodes.

In v4.0.x, the XPathNavigator selects the firstChild...

e.g. return mXml.CreateNavigator().Select("/node");


In v4.5, the current node (document element / root) is selected...

e.g. return xd.CreateNavigator().Select("."); // this is returned from 'getMediaDo'


The problem could be corrected by setting the node position to the firstChild... like so:

return xd.CreateNavigator().Select("/*");


Regards,
- Lee

File Attachments

No files are attached

Closed Jul 19 2010 at 10:27 AM by

Comments

leekelleher wrote Jul 19 2010 at 10:45 AM
Excellent, thanks Niels!

wrote Jul 19 2010 at 10:27 AM
Resolved with changeset 73319.

greystate wrote Jul 18 2010 at 9:53 PM
Yeah, this is weird - when you set a variable in XSLT to the result of a call to GetMedia(1200, 0) - you'd definitely expect that the id attribute of that variabler eference would return '1200', i.e.:







leekelleher wrote Jul 18 2010 at 9:31 PM
Just noticed in the 4.1.0 branch, there there is a line above the return commented out...

// string xpath = UmbracoSettings.UseLegacyXmlSchema ? "/node" : String.Format("/{0}", m.ContentType.Alias)

That would resolve the issue. Curious why was it commented out?

Updating...
© 2006-2012 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2012.2.7.18398