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

Parsing Error - undefined prefix #205

Open
Flexicoder opened this issue Jul 22, 2017 · 1 comment
Open

Parsing Error - undefined prefix #205

Flexicoder opened this issue Jul 22, 2017 · 1 comment

Comments

@Flexicoder
Copy link

Hi

I've upgraded our apps library from 2.1.0 to 2.1.1 to support Android N, but know when it tries to read the directory information for an Album I get the following error

07-22 12:59:43.849 com.bayanaudio.silverpoint W/System.err: org.xmlpull.v1.XmlPullParserException: undefined prefix: sec (position:START_TAG <{null}sec:dcmInfo>@2:364 in java.io.StringReader@fc5b6b7) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.kxml2.io.KXmlParser.checkRelaxed(KXmlParser.java:305) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.kxml2.io.KXmlParser.adjustNsp(KXmlParser.java:286) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.kxml2.io.KXmlParser.parseStartTag(KXmlParser.java:1153) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:372) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:313) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.xmlpull.v1.sax2.Driver.parseSubTree(Driver.java:449) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.xmlpull.v1.sax2.Driver.parse(Driver.java:340) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.seamless.xml.SAXParser.parse(SAXParser.java:107) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.fourthline.cling.support.contentdirectory.DIDLParser.parse(DIDLParser.java:118) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.fourthline.cling.support.contentdirectory.callback.Browse.success(Browse.java:109) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.fourthline.cling.controlpoint.ActionCallback.run(ActionCallback.java:160) 07-22 12:59:43.850 com.bayanaudio.silverpoint W/System.err: at org.fourthline.cling.support.contentdirectory.callback.Browse.run(Browse.java:89)

Is this something wrong with the DLNA info on the drive <{null} certainly doesn't look like a valid XML node?

@ryanheise
Copy link

I have the same error. It's because the server is sending back an invalid response that's missing a required namespace. Specifically, it's including the sec:dcmInfo element but it does not declare the namespace with xmlns:sec=".......".

In my case, the server is minidlna 1.2. If you don't really need the sec:dcmInfo property, you may be able to adjust your filter. Using "*" as the filter should in theory exclude the sec:... properties, but in my case I'm requesting them in the filter because my client needs them.

Interestingly, the Cling source already seems to contain some code to work around missing namespaces. In cling/core/src/main/java/org/fourthline/cling/binding/xml/RecoveringUDA10DeviceDescriptorBinderImpl.java there is a method called fixMissingNamespaces which does this:

        // Add missing namespace, it only matters that it is defined, not that it is correct
        return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
            + "<root "
            + String.format(Locale.ROOT, "xmlns:%s=\"urn:schemas-dlna-org:device-1-0\"", missingNS) + rootAttributes + ">"
            + rootBody
            + "</root>";

        // TODO: Should we match different undeclared prefixes with their correct namespace?
        // So if it's "dlna" we use "urn:schemas-dlna-org:device-1-0" etc.

As you can see, it's hard coded to fix one specific missing namespace and unfortunately it's not the one that we want.

I think a more general solution is needed that will detect and insert all missing namespaces. To answer the question in the source comment above, I think that if you want a map of known missing namespaces, that's fine, although it should at least default to just inserting a made-up namespace since, as you point out, it only matters that it's defined, not that it's correct.

I'm new to cling so I haven't used 2.1.0. Are you saying this used to work and it stopped working in 2.1.1? If that's the case, I just might need to try out 2.1.0 :-) Although it'd be nice to have a more general workaround in 2.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants