From c29604d5536ba029314b65a44325e61a626ec6af Mon Sep 17 00:00:00 2001 From: jez Date: Sun, 19 Dec 2010 23:22:17 +0000 Subject: [PATCH] set attributes readonly when its owner element is readonly --- include/DOM/Simple/NodeImpl.hpp | 6 +++- include/SAX/wrappers/saxexpat.hpp | 12 +++++++ src/SAX/wrappers/saxexpat.cpp | 7 +++++ vs10/Arabica_noboost.sln | 45 ++++++--------------------- vs10/example_DOM_writer.vcxproj | 8 +++-- vs10/example_SAX_Taggle.vcxproj | 8 +++-- vs10/example_SAX_pyx.vcxproj | 8 +++-- vs10/example_SAX_simplehander.vcxproj | 8 +++-- vs10/example_SAX_writer.vcxproj | 8 +++-- vs10/example_SAX_xmlbase.vcxproj | 8 +++-- vs10/example_Utils_transcode.vcxproj | 8 +++-- 11 files changed, 75 insertions(+), 51 deletions(-) diff --git a/include/DOM/Simple/NodeImpl.hpp b/include/DOM/Simple/NodeImpl.hpp index 18026b6c..136a77c0 100644 --- a/include/DOM/Simple/NodeImpl.hpp +++ b/include/DOM/Simple/NodeImpl.hpp @@ -190,8 +190,12 @@ class NodeImpl : virtual public DOM::Node_impl { // Should be readOnly_ = readOnly; ? readOnly_ = true; - for(NodeImplT*child = getFirst(); child != 0; child = child->getNext()) + for(NodeImplT* child = getFirst(); child != 0; child = child->getNext()) child->setReadOnly(readOnly_); + DOMNamedNodeMap_implT* attrs = getAttributes(); + if(attrs) + for(unsigned int i = 0; i < attrs->getLength(); ++i) + (dynamic_cast(attrs->item(i)))->setReadOnly(readOnly_); } // setReadOnly void throwIfReadOnly() const diff --git a/include/SAX/wrappers/saxexpat.hpp b/include/SAX/wrappers/saxexpat.hpp index c377b094..7f169cf4 100644 --- a/include/SAX/wrappers/saxexpat.hpp +++ b/include/SAX/wrappers/saxexpat.hpp @@ -74,6 +74,7 @@ void ewim_endDoctypeDecl(void* userData); void ewim_startCdataSection(void* userData); void ewim_endCdataSection(void* userData); void ewim_commentHandler(void* userData, const XML_Char* data); +void ewim_skippedEntityHandler(void* userData, const XML_Char* entityName, int is_parameter_entity); int ewim_externalEntityRefHandler(XML_Parser parser, const XML_Char* context, const XML_Char* base, @@ -119,6 +120,7 @@ private: virtual void startCdataSection() = 0; virtual void endCdataSection() = 0; virtual void commentHandler(const XML_Char* data) = 0; + virtual void skippedEntity(const XML_Char* entityName) = 0; virtual int externalEntityRefHandler(XML_Parser parser, const XML_Char* context, const XML_Char* base, @@ -139,6 +141,7 @@ private: friend void ewim_startCdataSection(void*); friend void ewim_endCdataSection(void*); friend void ewim_commentHandler(void*, const XML_Char*); + friend void ewim_skippedEntityHandler(void*, const XML_Char*, int); friend int ewim_externalEntityRefHandler(XML_Parser, const XML_Char*, const XML_Char*, const XML_Char*, const XML_Char*); }; // class expat2base @@ -309,6 +312,7 @@ class expat_wrapper : virtual void startCdataSection(); virtual void endCdataSection(); virtual void commentHandler(const XML_Char* data); + virtual void skippedEntity(const XML_Char* entityName); virtual int externalEntityRefHandler(XML_Parser parser, const XML_Char* context, const XML_Char* base, @@ -387,6 +391,7 @@ void expat_wrapper::setCallbacks() XML_SetDoctypeDeclHandler(parser_, expat_wrapper_impl_mumbojumbo::ewim_startDoctypeDecl, expat_wrapper_impl_mumbojumbo::ewim_endDoctypeDecl); XML_SetCdataSectionHandler(parser_, expat_wrapper_impl_mumbojumbo::ewim_startCdataSection, expat_wrapper_impl_mumbojumbo::ewim_endCdataSection); XML_SetCommentHandler(parser_, expat_wrapper_impl_mumbojumbo::ewim_commentHandler); + XML_SetSkippedEntityHandler(parser_, expat_wrapper_impl_mumbojumbo::ewim_skippedEntityHandler); XML_SetExternalEntityRefHandler(parser_, expat_wrapper_impl_mumbojumbo::ewim_externalEntityRefHandler); XML_SetProcessingInstructionHandler(parser_, expat_wrapper_impl_mumbojumbo::ewim_processingInstruction); } // setCallbacks @@ -1009,6 +1014,13 @@ void expat_wrapper::commentHandler(const XML_Char *data) lexicalHandler_->comment(SA::construct_from_utf8(data)); } // commentHandler +template +void expat_wrapper::skippedEntity(const XML_Char *entityName) +{ + if(contentHandler_) + contentHandler_->skippedEntity(SA::construct_from_utf8(entityName)); +} // skippedEntity + template int expat_wrapper::externalEntityRefHandler(XML_Parser parser, const XML_Char* context, diff --git a/src/SAX/wrappers/saxexpat.cpp b/src/SAX/wrappers/saxexpat.cpp index 4dfa5bec..e1ece7c9 100644 --- a/src/SAX/wrappers/saxexpat.cpp +++ b/src/SAX/wrappers/saxexpat.cpp @@ -119,6 +119,13 @@ void ewim_commentHandler(void* userData, const XML_Char* data) p->commentHandler(data); } // commentHandler +void ewim_skippedEntityHandler(void* userData, const XML_Char* entityName, int is_parameter_entity) +{ + expat2base* p = reinterpret_cast(userData); + p->skippedEntity(entityName); +} // skippedEntityHandler + + int ewim_externalEntityRefHandler(XML_Parser parser, const XML_Char* context, const XML_Char* base, diff --git a/vs10/Arabica_noboost.sln b/vs10/Arabica_noboost.sln index b0658a21..6b30360f 100644 --- a/vs10/Arabica_noboost.sln +++ b/vs10/Arabica_noboost.sln @@ -1,47 +1,20 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_Pyx", "example_SAX_pyx.vcproj", "{5214A867-2768-4CD0-9E29-6EED20718556}" - ProjectSection(ProjectDependencies) = postProject - {4CA72415-D03A-4447-BE4E-C093A5146CAC} = {4CA72415-D03A-4447-BE4E-C093A5146CAC} - {436B423B-BF20-4B2E-A187-604AF391FBE2} = {436B423B-BF20-4B2E-A187-604AF391FBE2} - EndProjectSection +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_pyx", "example_SAX_pyx.vcxproj", "{5214A867-2768-4CD0-9E29-6EED20718556}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_SimpleHandler", "example_SAX_simplehander.vcproj", "{4D861155-0183-4637-8F01-4F8FDB43C344}" - ProjectSection(ProjectDependencies) = postProject - {4CA72415-D03A-4447-BE4E-C093A5146CAC} = {4CA72415-D03A-4447-BE4E-C093A5146CAC} - {436B423B-BF20-4B2E-A187-604AF391FBE2} = {436B423B-BF20-4B2E-A187-604AF391FBE2} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_SimpleHandler", "example_SAX_simplehander.vcxproj", "{4D861155-0183-4637-8F01-4F8FDB43C344}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_Writer", "example_SAX_writer.vcproj", "{C57BA030-A81F-4EA2-9CB6-D1BE2404B787}" - ProjectSection(ProjectDependencies) = postProject - {4CA72415-D03A-4447-BE4E-C093A5146CAC} = {4CA72415-D03A-4447-BE4E-C093A5146CAC} - {436B423B-BF20-4B2E-A187-604AF391FBE2} = {436B423B-BF20-4B2E-A187-604AF391FBE2} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_writer", "example_SAX_writer.vcxproj", "{C57BA030-A81F-4EA2-9CB6-D1BE2404B787}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_XMLBase", "example_SAX_xmlbase.vcproj", "{1E3CEC10-26EB-40C0-AC9A-72020BD5A40A}" - ProjectSection(ProjectDependencies) = postProject - {4CA72415-D03A-4447-BE4E-C093A5146CAC} = {4CA72415-D03A-4447-BE4E-C093A5146CAC} - {436B423B-BF20-4B2E-A187-604AF391FBE2} = {436B423B-BF20-4B2E-A187-604AF391FBE2} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_xmlbase", "example_SAX_xmlbase.vcxproj", "{1E3CEC10-26EB-40C0-AC9A-72020BD5A40A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_DOM_Writer", "example_DOM_writer.vcproj", "{C1CF7801-1681-4F15-8D71-BBC814805AF2}" - ProjectSection(ProjectDependencies) = postProject - {1E3CEC10-26EB-40C0-AC9A-72020BD5A40A} = {1E3CEC10-26EB-40C0-AC9A-72020BD5A40A} - {4CA72415-D03A-4447-BE4E-C093A5146CAC} = {4CA72415-D03A-4447-BE4E-C093A5146CAC} - {C57BA030-A81F-4EA2-9CB6-D1BE2404B787} = {C57BA030-A81F-4EA2-9CB6-D1BE2404B787} - {436B423B-BF20-4B2E-A187-604AF391FBE2} = {436B423B-BF20-4B2E-A187-604AF391FBE2} - {4D861155-0183-4637-8F01-4F8FDB43C344} = {4D861155-0183-4637-8F01-4F8FDB43C344} - {5214A867-2768-4CD0-9E29-6EED20718556} = {5214A867-2768-4CD0-9E29-6EED20718556} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_DOM_writer", "example_DOM_writer.vcxproj", "{C1CF7801-1681-4F15-8D71-BBC814805AF2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_Utils_Transcode", "example_Utils_transcode.vcproj", "{436B423B-BF20-4B2E-A187-604AF391FBE2}" - ProjectSection(ProjectDependencies) = postProject - {4CA72415-D03A-4447-BE4E-C093A5146CAC} = {4CA72415-D03A-4447-BE4E-C093A5146CAC} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_Utils_transcode", "example_Utils_transcode.vcxproj", "{436B423B-BF20-4B2E-A187-604AF391FBE2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArabicaLib", "lib_arabica_noboost.vcproj", "{4CA72415-D03A-4447-BE4E-C093A5146CAC}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_Taggle", "example_SAX_Taggle.vcproj", "{274EB942-0AA8-4715-8419-4722868A22BA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_SAX_Taggle", "example_SAX_Taggle.vcxproj", "{274EB942-0AA8-4715-8419-4722868A22BA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/vs10/example_DOM_writer.vcxproj b/vs10/example_DOM_writer.vcxproj index d300585f..c901d6dc 100644 --- a/vs10/example_DOM_writer.vcxproj +++ b/vs10/example_DOM_writer.vcxproj @@ -1,4 +1,4 @@ - + @@ -43,7 +43,7 @@ .\..\bin\ .\Release_examples_DOM_writer\ false - DOMWriter + DOMWriter @@ -125,6 +125,10 @@ {1e3cec10-26eb-40c0-ac9a-72020bd5a40a} false + + {436b423b-bf20-4b2e-a187-604af391fbe2} + false + {4ca72415-d03a-4447-be4e-c093a5146cac} false diff --git a/vs10/example_SAX_Taggle.vcxproj b/vs10/example_SAX_Taggle.vcxproj index c0a4188a..94140b4b 100644 --- a/vs10/example_SAX_Taggle.vcxproj +++ b/vs10/example_SAX_Taggle.vcxproj @@ -1,4 +1,4 @@ - + @@ -40,7 +40,7 @@ .\Debug_example_SAX_taggle\ .\..\bin\ .\Release_example_SAX_taggle\ - taggle + taggle @@ -101,6 +101,10 @@ {4d861155-0183-4637-8f01-4f8fdb43c344} false + + {274eb942-0aa8-4715-8419-4722868a22ba} + false + {c57ba030-a81f-4ea2-9cb6-d1be2404b787} false diff --git a/vs10/example_SAX_pyx.vcxproj b/vs10/example_SAX_pyx.vcxproj index e94805a0..e9a2a107 100644 --- a/vs10/example_SAX_pyx.vcxproj +++ b/vs10/example_SAX_pyx.vcxproj @@ -1,4 +1,4 @@ - + @@ -44,7 +44,7 @@ .\..\bin\ .\Release_examples_SAX_pyx\ false - pyx + pyx @@ -120,6 +120,10 @@ + + {436b423b-bf20-4b2e-a187-604af391fbe2} + false + {4ca72415-d03a-4447-be4e-c093a5146cac} false diff --git a/vs10/example_SAX_simplehander.vcxproj b/vs10/example_SAX_simplehander.vcxproj index 21af084f..93928a69 100644 --- a/vs10/example_SAX_simplehander.vcxproj +++ b/vs10/example_SAX_simplehander.vcxproj @@ -1,4 +1,4 @@ - + @@ -45,7 +45,7 @@ .\..\bin\ .\Release_examples_SAX_simple\ false - simplehandler + simplehandler @@ -124,6 +124,10 @@ + + {436b423b-bf20-4b2e-a187-604af391fbe2} + false + {4ca72415-d03a-4447-be4e-c093a5146cac} false diff --git a/vs10/example_SAX_writer.vcxproj b/vs10/example_SAX_writer.vcxproj index 7042d009..ff77981d 100644 --- a/vs10/example_SAX_writer.vcxproj +++ b/vs10/example_SAX_writer.vcxproj @@ -1,4 +1,4 @@ - + @@ -44,7 +44,7 @@ .\..\bin\ .\Release_examples_SAX_writer\ false - Writer + Writer @@ -119,6 +119,10 @@ + + {436b423b-bf20-4b2e-a187-604af391fbe2} + false + {4ca72415-d03a-4447-be4e-c093a5146cac} false diff --git a/vs10/example_SAX_xmlbase.vcxproj b/vs10/example_SAX_xmlbase.vcxproj index 2be5ea11..710423ef 100644 --- a/vs10/example_SAX_xmlbase.vcxproj +++ b/vs10/example_SAX_xmlbase.vcxproj @@ -1,4 +1,4 @@ - + @@ -43,7 +43,7 @@ .\..\bin\ .\Release_examples_SAX_xmlbase\ false - xmlbase + xmlbase @@ -101,6 +101,10 @@ + + {436b423b-bf20-4b2e-a187-604af391fbe2} + false + {4ca72415-d03a-4447-be4e-c093a5146cac} false diff --git a/vs10/example_Utils_transcode.vcxproj b/vs10/example_Utils_transcode.vcxproj index 9b6ebd45..1bf1ca8a 100644 --- a/vs10/example_Utils_transcode.vcxproj +++ b/vs10/example_Utils_transcode.vcxproj @@ -1,4 +1,4 @@ - + @@ -43,7 +43,7 @@ .\..\bin\ .\Release_example_Utils_transcode\ false - transcode + transcode @@ -106,6 +106,10 @@ + + {436b423b-bf20-4b2e-a187-604af391fbe2} + false + {4ca72415-d03a-4447-be4e-c093a5146cac} false