Inserting extra XML in Device Description and Service SCPD XML (1 Viewer)

McGoober

Retired Team Member
  • Premium Supporter
  • August 13, 2006
    122
    105
    Cambridge, UK
    United Kingdom United Kingdom
    One of the requirements of DLNA is to add the following XML tag to UPNP device description and service SCPD XML.

    Code:
    <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
    Currently there is no way for me to insert this XML tag into either of the xml documents.
    In order to make my UPNP device and services I subclass both DvDevice and DvService. I was wondering if a virtual method could be put into each of these classes, such that I could override them and insert whatever into the XML.

    Something like this...

    Code:
    class DvDevice {
        (BLAH)
    
        internal void AddDeviceDescriptionsRecursive(XmlWriter writer, EndpointConfiguration config, CultureInfo culture)
        {
             (BLAH)
             AddAdditionalDeviceDescriptions(writer, config, culture);
             (BLAH)
        }
    
    
        protected virtual void AddAdditionalDeviceDescriptions(XmlWriter writer, EndpointConfiguration config, CultureInfo culture)
        {
            // Nothing to do here for DvDevice, but could be overriden by a subclass.
        }
    }

    I could then do the following...


    Code:
    class UPnPMediaServerDevice : DvDevice {
          (BLAH)
            protected override void AddAdditionalDeviceDescriptions(XmlWriter writer, EndpointConfiguration config, CultureInfo culture)
            {
                // Add DLNA specific Element.
                writer.WriteElementString("dlna", "X_DLNADOC", "urn:schemas-dlna-org:device-1-0", "DMR-1.50");
            }
          (BLAH)
    }
    Hope that makes sense. Any other ideas are of course welcome.
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    41
    Freiburg im Breisgau, Germany
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    McGoober, can you point me to a document which describes the place where to put that DLNA element in the device description and service SCPD documents? UPnP 1.1 lets me put new XML elements at the end of each complex standard element (see "UPnP-arch-DeviceArchitecture-v1 1-20081015.pdf", 2.7.1).
     

    McGoober

    Retired Team Member
  • Premium Supporter
  • August 13, 2006
    122
    105
    Cambridge, UK
    United Kingdom United Kingdom
    I've looked through the specs. DLNA is based on UPnP v1.0 and according to the spec can include vender XML anywhere in the doc so long as it is well formed. UPnP 1.1 seems more restrictive but does have a clause for UPnP 1.0 devices in UPNP device arch v1.1 part 2.7.1 under exception. I know it's not ideal.
    I'm happy with it just after the deviceList element.

    DLNA only requires the element in the device XML not the service scpd. I swear I read it needs to be in the service... Oh well.
     

    McGoober

    Retired Team Member
  • Premium Supporter
  • August 13, 2006
    122
    105
    Cambridge, UK
    United Kingdom United Kingdom
    I seem to be getting confused here. I was thinking that a complex type was an argument type from the service rather than a XML schema thing. Vendor XML can appear in any element so long as it's defined as a complex type in the schema. Therefore allowing extra under the root element.
    Did you want to allow the ability to insert XML anywhere in the document in accordance with the spec, or did you just want some arbitrary point for insertion? I guess if you desire an sdk like approach then spec conformance wins. I guess the question now is, how would one code this, given that currently XML is generated from a list of write element/attribute calls. Interesting.
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    41
    Freiburg im Breisgau, Germany
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    Well, complex types can transfer their content via an XML structure, but they are used exactly like standard types.
    We use complex types for example for shares or for metadata extractor metadata structures. Such types are serialized and deserialized via extra classes, for example class Share.
    But I don't understand the connection to this thread, maybe that is what you want to say: Inserting extra XML is a new feature which needs to be coded somewhere. And yes, I also have my problems to find a way to let the user of the UPnP library insert extra XML at arbitrary positions. That's one reason why I asked you for the specs.
     

    McGoober

    Retired Team Member
  • Premium Supporter
  • August 13, 2006
    122
    105
    Cambridge, UK
    United Kingdom United Kingdom
    I just thought. What about instead of coding against a serialising XML writer, how about making a DOM object and passing that to the virtual method. That way the programmer can add whatever XML they wish to any part of the document then after they are done you can serialise it.
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    41
    Freiburg im Breisgau, Germany
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    That would be possible, but expensive because we would need to build that DOM tree. If nothing else helps, we can do something like that. But I'm given to use something like the visitor pattern; the extension can inject a delegate which will be called at the end of each XML generate method, or something.
     

    McGoober

    Retired Team Member
  • Premium Supporter
  • August 13, 2006
    122
    105
    Cambridge, UK
    United Kingdom United Kingdom
    Oh, sounds interesting. Look forward to reading the code.
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    Top Bottom