CXML structure

From PS4 Developer wiki
Jump to: navigation, search

XML implicit structure Overview[edit]

 namespace cxml
 {
 	struct Header { /*header of a cxml document*/
                char magic[4];
                int version;
                int tree_offset;
                int tree_size;
                int idstrtable_offset;
                int idstrtable_size;
                int idinttable_offset;
                int idinttable_size;
                int stringtable_offset;
                int stringtable_size;
                int styleidtable_offset;
                int styleidtable_size;
                int intarraytable_offset;
                int intarraytable_size;
                int floatarraytable_offset;
                int floatarraytable_size;
                int filetable_offset;
                int filetable_size;
        };
 
        struct ChildElementBin
        {
                int name;
                int attr_num;
                int parent;
                int prev;
                int next;
                int first_child;
                int last_child;
        };
 
        struct BrotherElementBin
        {
                int name;
                int attr_num;
                int parent;
                int prev;
                int next;
        };
 
        struct AttributeBin
        {
                int INTEGER = 1;
                int FLOAT = 2;
                int STRING = 3;
                int unk = 4;
                int STYLE_ID = 5;
                int INTEGER_ARRAY = 6;
                int FLOAT_ARRAY = 7;
                int DATA = 8;
                int ID_STR_REF = 9;
                int ID_STR_NO_REF = 10;
                int ID_INT_REF = 11;
                int ID_INT_NO_REF = 12;
                int name;
                int type;
 
                struct StringData
                {
                        int offset;
                        int len;
                };
 
                struct IntArrayData
                {
                        int offset;
                        int num;
                };
 
                struct FloatArrayData
                {
                        int offset;
                        int num;
                };
 
                struct FileData
                {
                        int offset;
                        int size;
                };
 
                union
                {
                        int i;
                        float f;
                        StringData s;
                        IntArrayData ia;
                        FloatArrayData fa;
                        FileData file;
                        int id;
                        int idref;
                };
        };
 
        struct IDBin
        {
                int entity_offset;
                char id[0];
        };
 
        enum AllocationType
        {
                AllocationType_Alloc_Tree,
                AllocationType_Alloc_IDSTRTable,
                AllocationType_Alloc_IDINTTable,
                AllocationType_Alloc_StringTable,
                AllocationType_Alloc_IntArrayTable,
                AllocationType_Alloc_FloatArrayTable,
                AllocationType_Alloc_FileTable,
                AllocationType_Alloc_StyleIDTable,
 
                AllocationType_Free_Tree,
                AllocationType_Free_IDSTRTable,
                AllocationType_Free_IDINTTable,
                AllocationType_Free_StringTable,
                AllocationType_Free_IntArrayTable,
                AllocationType_Free_FloatArrayTable,
                AllocationType_Free_FileTable,
                AllocationType_AFree_StyleIDTable,
        };
 
        enum AccessMode
        {
                AccessMode_ReadWrite,
                AccessMode_ReadOnly_File,
                AccessMode_ReadOnly_Memory,
        };
 
        class Document {
        public:
                typedef void (*Allocator)( AllocationType type, void * userdata, void * old_addr, unsigned int required_size, void ** addr, unsigned int * size );
 
        private:
                AccessMode access_mode;
                Header header;
                char * tree;
                unsigned int tree_capacity;
                char * idstrtable;
                unsigned int idstrtable_capacity;
                char * idinttable;
                unsigned int idinttable_capacity;
                char * stringtable;
                unsigned int stringtable_capacity;
                int * intarraytable;
                unsigned int intarraytable_capacity;
                float * floatarraytable;
                unsigned int floatarraytable_capacity;
                char * filetable;
                unsigned int filetable_capacity;
                char * styleidtable;
                unsigned int styleidtable_capacity;
                Allocator allocator;
                void * allocator_userdata;
        };
 
        class Element {
        private:
                Document * doc;
                int offset;
        };
 
        class Attribute {
        private:
                Document * doc;
                int element_offset;
                int offset;
        };
 };

Element[edit]

CXML Child Element definition
Offset Length usage
0x00 0x04 Element name relative offset in TAGS Table
0x04 0x04 Number of attributes in TOC
0x08 0x04 Parent relative offset in TOC
0x0C 0x04 Previous Brother relative offset in TOC
0x10 0x04 Next Brother relative offset in TOC
0x14 0x04 First child relative offset in TOC
0x18 0x04 Last child relative offset in TOC
CXML Brother Element definition
Offset Length usage
0x00 0x04 Element name relative offset in TAGS Table
0x04 0x04 Number of attributes in TOC
0x08 0x04 Parent relative offset in TOC
0x1C 0x04 Previous Brother relative offset in TOC
0x10 0x04 Next Brother relative offset in TOC
  • NOTE: The Child Element defination describe the Child Element and his Attributes where the Brother Element describe the Brother Element and his Attributes.

So the full order to read will be Child Element >>> Attributes, Brother Element >>> Attributes. The Root (so offset 0x00) of any SonyPlaystation Resource file always start's with a Child element to read.

Attribute[edit]

CXML Attribute definitions
Attribute name
(offset 0x0, length 0x4)
Attribute name relative offset in TAGS Table
Attribute type
(offset 0x4, length 0x4)
1
(Single Integer)
2
(Single Float)
3
(String)
4
(analysing...)
5
(ID STYLE)
6
(Integer Array)
7
(Float Array)
8
(File)
9
(ID STR w lpb Ref)
A
(ID STR wo lpb Ref)
B
(ID INT w lpb Ref)
C
(ID INT wo lpb Ref)
variable 1
(offset 0x8, length 0x4)
Integer value Float value Strings Table offset analysing... ID STYLE Table offset Integer Arrays Table offset Float Arrays Table offset Files Table offset ID STR Table offset ID STR Table offset ID INT Table offset ID INT Table offset
variable 2
(offset 0xC, length 0x4)
Not used (always 0) Not used (always 0) String length analysing... Nr. of int's to read (always 4) Nr. of int's to read Nr. of float's to read File size Not used (always 0) Not used (always 0) Not used (always 0) Not used (always 0)
* w = with || wo = without || lpb = loopback


XML Output[edit]

This is the Output, saved as xml, from the notification_settings_plugin.rco

download notification_settings_plugin.xml from FW??

*Note: That xml below isn't perfect right now. Especially the values from <styletable> need to be corrected. I'll change the xml here as soon i finished the CXML Tool and got a nice correct xml written out.
 <?xml version="1.0" encoding="UTF-8"?>
 <resource version="0.1" type="normal">
  <stringtable>
     <local origsize="1040" src="xmls/ja.xml"    compress="on" id="ja"/>
     <local origsize="1248" src="xmls/en-gb.xml" compress="on" id="en-gb"/>
     <local origsize="1248" src="xmls/en.cml"    compress="on" id="en"/>
     <local origsize="1328" src="xmls/fr.xml"    compress="on" id="fr"/>
     <local origsize="1392" src="xmls/es.xml"    compress="on" id="es"/>
     <local origsize="1312" src="xmls/de.xml"    compress="on" id="de"/>
     <local origsize="1280" src="xmls/it.xml"    compress="on" id="it"/>
     <local origsize="1296" src="xmls/nl.xml"    compress="on" id="nl"/>
     <local origsize="1312" src="xmls/pt-br.xml" compress="on" id="pt-br"/>
     <local origsize="1296" src="xmls/pt.xml"    compress="on" id="pt"/>
     <local origsize="1312" src="xmls/ru.xml"    compress="on" id="ru"/>
     <local origsize="1040" src="xmls/ko.xml"    compress="on" id="ko"/>
     <local origsize="992"  src="xmls/zh-t.xml"  compress="on" id="zh-t"/>
     <local origsize="992"  src="xmls/zh-s.xml"  compress="on" id="zh-s"/>
     <local origsize="1264" src="xmls/fi.xml"    compress="on" id="fi"/>
     <local origsize="1232" src="xmls/sv.xml"    compress="on" id="sv"/>
     <local origsize="1232" src="xmls/da.xml"    compress="on" id="da"/>
     <local origsize="1232" src="xmls/no.xml"    compress="on" id="no"/>
     <local origsize="1296" src="xmls/pl.xml"    compress="on" id="pl"/>
     <local origsize="1296" src="xmls/tr.xml"    compress="on" id="tr"/>
  </stringtable>
  <texturetable>
     <texture origsize="5328" src="texture/1DDD0E08.gim"  compress="on" id="1DDD0E08"  type="texture/gim"/>
     <texture origsize="7632" src="texture/2133CEEB.gim"  compress="on" id="2133CEEB"  type="texture/gim"/>
     <texture origsize="7632" src="texture/F7988312.gim" compress="on" id="F7988312" type="texture/gim"/>
     <texture origsize="5328" src="texture/6F57E251.gim" compress="on" id="6F57E251" type="texture/gim"/>
     <texture origsize="7632" src="texture/86645D41.gim" compress="on" id="86645D41" type="texture/gim"/>
     <texture src="texture/29B91F26.gim"  origsize="57648" div_ratio_h="0.49" compress="on" margin_v="1" id="29B91F26"  margin_h="1" type="texture/gim" div_mode="3x1"/>
     <texture src="texture/D0A272A1.gim" origsize="57648" div_ratio_h="0.49" compress="on" margin_v="1" id="D0A272A1" margin_h="1" type="texture/gim" div_mode="3x1"/>
  </texturetable>
  <styletable>
     <style_button id="86009135" bg_obj="1, 0, 0, 0" glow_obj="0, 0, 0, 0">
        <planeobj texture0="261FB929" id="01000000"/>
        <planeobj texture0="A172A2D0" blend="2" id="00000000" />
        <style_text textobj="00000000" id="E98E283C"/>
            <textobj font_size="28" bold="1" color="0.49, 1, 1, 1" max_line_count="1" line_pitch="28" word_wrap="1" ellipsis="1" id="00000000"/>
        </style_text>
     </style_button>
     <style_plane id="D7F12CC7" planeobj="0, 0, 0, 0">
        <planeobj texture0="0DD14518" id="01000000"/>
     </style_plane>
     <pagetable>
        <templatetable>
            <template id="9174183F">
                <file_list style="4B363870" id="04000000"/>
                <layout_hint align="0, 0" size="960, 448" id="00000000" pos="0, 0"/>
            </template>
            <template fast_open="1" id="60FB37AF">
                <list_item style="998F48F3" id="02000000">
                    <layout_hint align="0, 0" size="840, 80" id="00000000" pos="448, 0"/>
                    <text style="E98E283C" id="01000000">
                        <layout_hint size="462, 0" align="1, 0" adjust="0, 0" id="05000000" pos="-272, 0"/>
                        <plane style="2B337B5F" id="02000000">
                            <layout_hint pos="-30, 0" id="05000000" adjust="0, 0" alpha="0" anchor="1, 0" size="60, 60"/>
                        </plane>
                        <check_box style="98F8209F" id="00000000">
                            <layout_hint align="2, 0" size="46, 46" pos="602, 0" anchor="1, 0" id="05000000"/>
                            <focus_hint focus_shape="0" focus_size="47, 47"/>
                        </check_box>
                    </text>
                </list_item>
            </template>
            <template fast_open="1" id="23860CE8">
                <list_item style="998F48F3" id="02000000">
                    <layout_hint align="0, 0" size="840, 80" id="00000000" pos="0, 0"/>
                    <button sound="74324120" style="0520652F" id="00000000">
                        <layout_hint size="840, 80" adjust="1, 0" id="01000000" pos="0, 0"/>
                        <focus_hint focus_shape="3" focus_hint="960, 80"/>
                        <text style="E98E283C" id="02000000">
                            <layout_hint size="-206, 0" align="0, 0" adjust="4, 0" id="01000000" pos="0, 330"/>
                            <file_list style="2B337B5F" id="05000000">
                                <layout_hint pos="0, -40" id="01000000" adjust="1, 0" alpha="0" anchor="2, 0" size="60, 60"/>
                            </file_list>
                        </text>
                        <plane style="D7F12CC7" id="D9904322">
                            <layout_hint size="46, 46" align="5, 2" adjust="1, 0" id="EEA339DA" pos="330, 0"/>
                        </plane>
                    </button>
                </list_item>
            </template>
        </templatetable>
     </pagetable>
  </styletable>
 </resource>
 </xml>