Changes in Xerces for AppxBundle

This commit is contained in:
Ruben Guerrero Samaniego 2018-03-27 11:31:17 -07:00 коммит произвёл msftrubengu
Родитель eeae5726ad
Коммит 5e14b6cc29
2 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -7,6 +7,7 @@
set(RESOURCES_CERTS)
set(RESOURCES_BLOCKMAP)
set(RESOURCES_CONTENTTYPE)
set(RESOURCES_APPXTYPES)
set(RESOURCES_APPXMANIFEST)
set(RESOURCES_APPXBUNDLEMANIFEST)
@ -32,8 +33,11 @@ list(APPEND RESOURCES_BLOCKMAP
# AppxManifests
if(HAVE_MSXML6)
# Used by AppxManifest and AppxBundleManifest
list(APPEND RESOURCES_APPXTYPES
"AppxPackaging/Manifest/Schema/2015/AppxManifestTypes.xsd")
list(APPEND RESOURCES_APPXMANIFEST
"AppxPackaging/Manifest/Schema/2015/AppxManifestTypes.xsd"
"AppxPackaging/Manifest/Schema/2015/AppxPhoneManifestSchema2014.xsd"
"AppxPackaging/Manifest/Schema/2015/ComManifestSchema.xsd"
"AppxPackaging/Manifest/Schema/2015/DesktopManifestSchema.xsd"
@ -62,25 +66,25 @@ if(HAVE_MSXML6)
"AppxPackaging/Manifest/Schema/2017/RestrictedCapabilitiesManifestSchema_v4.xsd"
"AppxPackaging/Manifest/Schema/2017/UapManifestSchema_v5.xsd"
"AppxPackaging/Manifest/Schema/2017/UapManifestSchema_v6.xsd")
else() # xerces
# TODO: make changes required to make the xsds WC3 compliant.
endif()
list(APPEND RESOURCES_APPXBUNDLEMANIFEST
list(APPEND RESOURCES_APPXBUNDLEMANIFEST
"AppxPackaging/Manifest/Schema/2015/BundleManifestSchema2014.xsd"
"AppxPackaging/Manifest/Schema/2016/BundleManifestSchema2016.xsd"
"AppxPackaging/Manifest/Schema/2017/BundleManifestSchema2017.xsd")
else() # xerces
# TODO: make changes required to make the xsds WC3 compliant.
endif()
endif(USE_VALIDATION_PARSER)
# Create zip file. Use execute_process to run the command while CMake is procesing.
message(STATUS "Resource files:")
foreach(FILE ${RESOURCES_BLOCKMAP} ${RESOURCES_CONTENTTYPE} ${RESOURCES_APPXMANIFEST} ${RESOURCES_CERTS} ${RESOURCES_APPXBUNDLEMANIFEST})
foreach(FILE ${RESOURCES_CERTS} ${RESOURCES_BLOCKMAP} ${RESOURCES_CONTENTTYPE} ${RESOURCES_APPXTYPES} ${RESOURCES_APPXMANIFEST} ${RESOURCES_APPXBUNDLEMANIFEST})
message(STATUS "\t${FILE}")
endforeach(FILE)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar cvf "${CMAKE_BINARY_DIR}/resources.zip" --format=zip -- ${RESOURCES_BLOCKMAP} ${RESOURCES_CONTENTTYPE} ${RESOURCES_APPXMANIFEST} ${RESOURCES_CERTS} ${RESOURCES_APPXBUNDLEMANIFEST}
COMMAND ${CMAKE_COMMAND} -E tar cvf "${CMAKE_BINARY_DIR}/resources.zip" --format=zip -- ${RESOURCES_BLOCKMAP} ${RESOURCES_CONTENTTYPE} ${RESOURCES_APPXMANIFEST} ${RESOURCES_CERTS} ${RESOURCES_APPXBUNDLEMANIFEST} ${RESOURCES_APPXTYPES}
WORKING_DIRECTORY "${CMAKE_PROJECT_ROOT}/resources"
OUTPUT_QUIET
)
@ -105,6 +109,7 @@ GetResourceHpp("${RESOURCES_CONTENTTYPE}" CONTENTTYPE_HPP)
GetResourceHpp("${RESOURCES_APPXMANIFEST}" APPXMANIFEST_HPP)
GetResourceHpp("${RESOURCES_CERTS}" CERTS_HPP)
GetResourceHpp("${RESOURCES_APPXBUNDLEMANIFEST}" APPXBUNDLEMANIFEST_HPP)
GetResourceHpp("${RESOURCES_APPXTYPES}" APPXTYPES_HPP)
set(RESOURCE_HEADER "//
//
@ -148,9 +153,11 @@ namespace MSIX {
${BLOCKMAP_HPP}
break;
case Resource::AppxManifest:
${APPXTYPES_HPP}
${APPXMANIFEST_HPP}
break;
case Resource::AppxBundleManifest:
${APPXTYPES_HPP}
${APPXBUNDLEMANIFEST_HPP}
break;
}

Просмотреть файл

@ -268,6 +268,8 @@ public:
auto grammarPool = std::make_unique<XERCES_CPP_NAMESPACE::XMLGrammarPoolImpl>(XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgMemoryManager);
m_parser = std::make_unique<XERCES_CPP_NAMESPACE::XercesDOMParser>(nullptr, XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgMemoryManager, grammarPool.get());
// For Non validation parser GetResources will return an empty vector for the ContentType, BlockMap and AppxBundleManifest.
// XercesDom will only parse the schemas if the vector is not empty. // If not, it will only see that it is valid xml.
bool HasSchemas = ((schemas != nullptr) && (schemas->begin() != schemas->end()));
m_parser->setValidationScheme(HasSchemas ?
XERCES_CPP_NAMESPACE::AbstractDOMParser::ValSchemes::Val_Always :
@ -370,8 +372,8 @@ public:
return ComPtr<IXmlDom>::Make<XercesDom>(stream, &contentTypeSchema);
}
case XmlContentType::AppxBundleManifestXml:
{ auto bundleSchema = GetResources(m_factory, Resource::Type::AppxBundleManifest);
return ComPtr<IXmlDom>::Make<XercesDom>(stream, &bundleSchema);
{ // TODO: pass schemas to validate AppxManifest. This only validates that is a well-formed xml
return ComPtr<IXmlDom>::Make<XercesDom>(stream);
}
}
ThrowError(Error::InvalidParameter);