Fix validating resource schema 28/308628/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 28 Mar 2024 07:57:21 +0000 (16:57 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 28 Mar 2024 09:01:50 +0000 (18:01 +0900)
Load schema directly from a file because there is an unknown problem that
cannot load schema from memory.

Change-Id: Ief4d14db71aadf865951e2f1e486fe782b207f3c
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
packaging/aul.spec
src/rsc-mgr/CMakeLists.txt
src/rsc-mgr/aul_rsc_mgr_internal.c
src/rsc-mgr/aul_rsc_mgr_schema.h [deleted file]
src/rsc-mgr/res.xsd [new file with mode: 0644]

index df8e22b..000b93e 100644 (file)
@@ -338,6 +338,7 @@ chsmack -a 'User::Home' %{TZ_SYS_DB}/.component.db-journal
 %files rsc-mgr
 %manifest %{name}-rsc-mgr.manifest
 %attr(0644,root,root) %{_libdir}/libaul-rsc-mgr.so.*
+%{_datadir}/aul/res.xsd
 
 %files rsc-mgr-devel
 %{_includedir}/aul/rsc-mgr/*.h
index a2a38ef..54463ec 100644 (file)
@@ -30,6 +30,7 @@ INSTALL(TARGETS ${TARGET_AUL_RSC_MGR} DESTINATION ${LIB_INSTALL_DIR}
 CONFIGURE_FILE(${TARGET_AUL_RSC_MGR}.pc.in ${TARGET_AUL_RSC_MGR}.pc @ONLY)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_AUL_RSC_MGR}.pc
     DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res.xsd DESTINATION ${SHARE_INSTALL_PREFIX}/aul/)
 
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
   DESTINATION include/aul/rsc-mgr
index 96f6fdd..37b2745 100644 (file)
@@ -26,7 +26,6 @@
 #include <bundle.h>
 
 #include "aul_rsc_mgr_internal.h"
-#include "aul_rsc_mgr_schema.h"
 
 static char *__get_attribute(xmlNode *xml_node, const char *name)
 {
@@ -182,6 +181,7 @@ static int __parse_resource(xmlNode *xml_node, resource_data_t **data)
        return 0;
 }
 
+#define SCHEMA_FILE SHARE_PREFIX"/res.xsd"
 static int __validate_schema(const char *path)
 {
        xmlSchemaParserCtxt *parser_ctxt;
@@ -189,7 +189,7 @@ static int __validate_schema(const char *path)
        xmlSchemaValidCtxt *valid_ctxt;
        int ret;
 
-       parser_ctxt = xmlSchemaNewMemParserCtxt(res_schema, sizeof(res_schema));
+       parser_ctxt = xmlSchemaNewParserCtxt(SCHEMA_FILE);
        if (parser_ctxt == NULL) {
                LOGE("failed to create parser context");
                return -1;
diff --git a/src/rsc-mgr/aul_rsc_mgr_schema.h b/src/rsc-mgr/aul_rsc_mgr_schema.h
deleted file mode 100644 (file)
index 5bae1ea..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __AUL_RSC_MGR_SCHEMA_H__
-#define __AUL_RSC_MGR_SCHEMA_H__
-
-static const char res_schema[] =
-"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" targetNamespace=\"http://tizen.org/ns/rm\" xmlns:packages=\"http://tizen.org/ns/rm\">"
-"  <xs:import namespace=\"http://www.w3.org/XML/1998/namespace\"/>"
-"  <xs:element name=\"res\">"
-"    <xs:complexType>"
-"      <xs:all>"
-"        <xs:element name=\"group-image\" type=\"packages:GroupContainer\" maxOccurs=\"1\" minOccurs=\"0\"/>"
-"        <xs:element name=\"group-layout\" type=\"packages:GroupContainer\" maxOccurs=\"1\" minOccurs=\"0\"/>"
-"        <xs:element name=\"group-sound\" type=\"packages:GroupContainer\" maxOccurs=\"1\" minOccurs=\"0\"/>"
-"        <xs:element name=\"group-bin\" type=\"packages:GroupContainer\" maxOccurs=\"1\" minOccurs=\"0\"/>"
-"      </xs:all>"
-"    </xs:complexType>"
-"  </xs:element>"
-"  <xs:complexType name=\"GroupContainer\">"
-"    <xs:sequence>"
-"      <xs:element name=\"node\" maxOccurs=\"unbounded\" minOccurs=\"0\">"
-"        <xs:complexType>"
-"          <xs:attribute name=\"folder\" type=\"xs:string\" use=\"required\"/>"
-"          <xs:attribute name=\"screen-dpi\" type=\"xs:integer\"/>"
-"          <xs:attribute name=\"screen-dpi-range\" type=\"xs:string\"/>"
-"          <xs:attribute name=\"screen-width-range\" type=\"xs:string\"/>"
-"          <xs:attribute name=\"screen-large\" type=\"xs:boolean\"/>"
-"          <xs:attribute name=\"screen-bpp\" type=\"xs:integer\"/>"
-"          <xs:attribute name=\"platform-version\" type=\"xs:string\"/>"
-"          <xs:attribute name=\"language\" type=\"xs:string\"/>"
-"        </xs:complexType>"
-"      </xs:element>"
-"    </xs:sequence>"
-"    <xs:attribute name=\"folder\" type=\"xs:string\" use=\"required\"/>"
-"  </xs:complexType>"
-"</xs:schema>";
-
-#endif
diff --git a/src/rsc-mgr/res.xsd b/src/rsc-mgr/res.xsd
new file mode 100644 (file)
index 0000000..ea85907
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tizen.org/ns/rm" xmlns:packages="http://tizen.org/ns/rm">
+  <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
+  <xs:element name="res">
+    <xs:complexType>
+      <xs:all>
+        <xs:element name="group-image" type="packages:GroupContainer" maxOccurs="1" minOccurs="0"/>
+        <xs:element name="group-layout" type="packages:GroupContainer" maxOccurs="1" minOccurs="0"/>
+        <xs:element name="group-sound" type="packages:GroupContainer" maxOccurs="1" minOccurs="0"/>
+        <xs:element name="group-bin" type="packages:GroupContainer" maxOccurs="1" minOccurs="0"/>
+      </xs:all>
+    </xs:complexType>
+  </xs:element>
+  <xs:complexType name="GroupContainer">
+    <xs:sequence>
+      <xs:element name="node" maxOccurs="unbounded" minOccurs="0">
+        <xs:complexType>
+          <xs:attribute name="folder" type="xs:string" use="required"/>
+          <xs:attribute name="screen-dpi" type="xs:integer"/>
+          <xs:attribute name="screen-dpi-range" type="xs:string"/>
+          <xs:attribute name="screen-width-range" type="xs:string"/>
+          <xs:attribute name="screen-large" type="xs:boolean"/>
+          <xs:attribute name="screen-bpp" type="xs:integer"/>
+          <xs:attribute name="platform-version" type="xs:string"/>
+          <xs:attribute name="language" type="xs:string"/>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="folder" type="xs:string" use="required"/>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file