SchemaSimpleContent.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "SchemaSimpleContent.hpp"
  14. #include "SchemaAnnotation.hpp"
  15. #include "SchemaExtension.hpp"
  16. #include "SchemaRestriction.hpp"
  17. using namespace CONFIGURATOR;
  18. #define IPropertyTree ::IPropertyTree
  19. CSimpleContent* CSimpleContent::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
  20. {
  21. if (pParentNode == nullptr || pSchemaRoot == nullptr)
  22. return nullptr;
  23. CExtension *pExtension = nullptr;
  24. CAnnotation *pAnnotation = nullptr;
  25. CRestriction *pRestriction = nullptr;
  26. IPropertyTree *pTree = pSchemaRoot->queryPropTree(xpath);
  27. if(pTree == nullptr)
  28. return nullptr;
  29. StringBuffer strXPathExt(xpath);
  30. strXPathExt.append("/").append(XSD_TAG_EXTENSION);
  31. if (pSchemaRoot->queryPropTree(strXPathExt.str()) != nullptr)
  32. {
  33. pExtension = CExtension::load(nullptr, pSchemaRoot, strXPathExt.str());
  34. if (pExtension != nullptr)
  35. pExtension->initExtension();
  36. }
  37. strXPathExt.set(xpath);
  38. strXPathExt.append("/").append(XSD_TAG_ANNOTATION);
  39. if (pSchemaRoot->queryPropTree(strXPathExt.str()) != nullptr)
  40. pAnnotation = CAnnotation::load(nullptr, pSchemaRoot, strXPathExt.str());
  41. strXPathExt.set(xpath);
  42. strXPathExt.append("/").append(XSD_TAG_RESTRICTION);
  43. if (pSchemaRoot->queryPropTree(strXPathExt.str()) != nullptr)
  44. pRestriction = CRestriction::load(nullptr, pSchemaRoot, strXPathExt.str());
  45. const char* pID = nullptr;
  46. pID = pTree->queryProp(XML_ATTR_ID);
  47. CSimpleContent *pSimpleContent = new CSimpleContent(pParentNode, pID);
  48. SETPARENTNODE(pExtension, pSimpleContent);
  49. SETPARENTNODE(pAnnotation, pSimpleContent);
  50. SETPARENTNODE(pRestriction, pSimpleContent);
  51. return pSimpleContent;
  52. }
  53. CSimpleContent::~CSimpleContent()
  54. {
  55. delete m_pRestriction;
  56. delete m_pAnnotation;
  57. delete m_pExtension;
  58. }
  59. bool CSimpleContent::checkConstraint(const char *pValue) const
  60. {
  61. return true;
  62. }