Opened 12 years ago

Closed 12 years ago

#3931 closed enhancement (wontfix)

PATCH: Add <include_file src="includefile.xml"/> functionality to xmlparser

Reported by: Roo <roo.watt@…> Owned by: Isaac Richards
Priority: minor Milestone: 0.21
Component: mythtv Version: head
Severity: medium Keywords: include xml parse
Cc: Ticket locked: no

Description

The attached patch adds an <include_src> tag to the xmlparser in libmyth/xmlparse.cpp.

parent_file,xml:

<mythuitheme>

    <include_file src="include_file.xml" />

    <!-- OR -->

    <include_file src="include_file.xml">
        Some comment text can go here.
    </include_file>

</mythuitheme>

included_file.xml:

<container>
   <font name="title" face="Arial">
       <color>#ffff00</color>
       <dropcolor>#000000</dropcolor>
       <size>24</size>
       <shadow>3,3</shadow>
       <bold>yes</bold>
   </font>

   <font name="labels" face="Arial">
       <color>#ffff00</color>
       <dropcolor>#000000</dropcolor>
       <size>18</size>
       <shadow>3,3</shadow>
       <bold>yes</bold>
   </font>
</container>

final_document:

<mythuitheme>

   <font name="title" face="Arial">
       <color>#ffff00</color>
       <dropcolor>#000000</dropcolor>
       <size>24</size>
       <shadow>3,3</shadow>
       <bold>yes</bold>
   </font>

   <font name="labels" face="Arial">
       <color>#ffff00</color>
       <dropcolor>#000000</dropcolor>
       <size>18</size>
       <shadow>3,3</shadow>
       <bold>yes</bold>
   </font>

    <!-- OR -->

   <font name="title" face="Arial">
       <color>#ffff00</color>
       <dropcolor>#000000</dropcolor>
       <size>24</size>
       <shadow>3,3</shadow>
       <bold>yes</bold>
   </font>

   <font name="labels" face="Arial">
       <color>#ffff00</color>
       <dropcolor>#000000</dropcolor>
       <size>18</size>
       <shadow>3,3</shadow>
       <bold>yes</bold>
   </font>

</mythuitheme>

Include file requirements

  • The included file must be a well formed xml document, errors will be reported
  • All children (of the root element) of the included document will be inserted into the parent document
  • A recursion limit protects from circular includes

Include search path

  • The included file will be searched for in the standard search path as used for the main xml file
  • If either the parent.xml file or any include_file.xml cannot be found in the search path then the file load fails

One possible use would allow a theme developer to only "theme" the desired <window>'s in a plugin without a needing to theme the entire plugin. I believe this will enable a finer grained level of reuse for theme files than the current plugin level.

eg The main mythmusic playback window could be themed but include the default/music-metadata.xml file for the meta data editor.

Attachments (2)

mythtv_xml_include_v1.diff (5.5 KB) - added by Roo <roo.watt@…> 12 years ago.
v1 of patch, search path for parent and inluded files
mythtv_xml_include_v2.diff (3.3 KB) - added by Roo <roo.watt@…> 12 years ago.
v2 addresses the issue raised by paulh

Download all attachments as: .zip

Change History (6)

Changed 12 years ago by Roo <roo.watt@…>

Attachment: mythtv_xml_include_v1.diff added

v1 of patch, search path for parent and inluded files

comment:1 Changed 12 years ago by paulh

One possible use would allow a theme developer to only "theme" the desired <window>'s in a plugin without a needing to theme the entire plugin. I believe this will enable a finer grained level of reuse for theme files than the current plugin level.

Are you sure it doesn't already do something like this? I can't be bothered to check now but it certainly used to look in the chosen theme file then if not found fall back to the default theme file.

http://www.gossamer-threads.com/lists/mythtv/dev/123109

A lot of things *have* moved around since that patch though in the UI rewrite.

comment:2 in reply to:  1 Changed 12 years ago by Roo <roo.watt@…>

Replying to paulh:

One possible use would allow a theme developer to only "theme" the desired <window>'s in a plugin without a needing to theme the entire plugin. I believe this will enable a finer grained level of reuse for theme files than the current plugin level.

Are you sure it doesn't already do something like this? I can't be bothered to check now but it certainly used to look in the chosen theme file then if not found fall back to the default theme file.

I think you are right Paul, the current version of the patch breaks that I think. I will look at it and fix it up.

Changed 12 years ago by Roo <roo.watt@…>

Attachment: mythtv_xml_include_v2.diff added

v2 addresses the issue raised by paulh

comment:3 Changed 12 years ago by Roo <roo.watt@…>

Having looked at the issue raised by paulh above I have updated the patch.

V1 of the patch definitely broke the <window name="win_name"> search.

comment:4 in reply to:  description Changed 12 years ago by paulh

Resolution: wontfix
Status: newclosed

Replying to Roo <roo.watt@gmail.com>:

One possible use would allow a theme developer to only "theme" the desired <window>'s in a plugin without a needing to theme the entire plugin. I believe this will enable a finer grained level of reuse for theme files than the current plugin level.

eg The main mythmusic playback window could be themed but include the default/music-metadata.xml file for the meta data editor.

The existing code allows for the above automatically. If a window definition isn't found in a theme then the default one will be used anyway.

If that is all you are trying to do then this patch is redundant and IMHO just complicates theme handling without any great benefit that I can see.

Note: See TracTickets for help on using tickets.