MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / loadFromInputSource

Method loadFromInputSource

src/App/Metadata.cpp:134–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134void Metadata::loadFromInputSource(const InputSource& source)
135{
136 // Any exception thrown by the XML code propagates out and prevents object creation
137 XMLPlatformUtils::Initialize();
138
139 _parser = std::make_shared<XercesDOMParser>();
140 _parser->setValidationScheme(XercesDOMParser::Val_Never);
141 _parser->setDoNamespaces(true);
142
143 auto errHandler = std::make_unique<MetadataInternal::XMLErrorHandler>();
144 _parser->setErrorHandler(errHandler.get());
145
146 _parser->parse(source);
147
148 auto doc = _parser->getDocument();
149 _dom = doc->getDocumentElement();
150
151 auto rootTagName = StrXUTF8(_dom->getTagName()).str;
152 if (rootTagName != "package") {
153 throw Base::XMLBaseException(
154 "Malformed package.xml document: Root <package> group not found");
155 }
156 auto formatVersion = XMLString::parseInt(_dom->getAttribute(XUTF8StrLiteral("format").unicodeForm()));
157 switch (formatVersion) {
158 case 1:
159 parseVersion1(_dom);
160 break;
161 default:
162 throw Base::XMLBaseException(
163 "package.xml format version is not supported by this version of FreeCAD");
164 }
165}
166
167Metadata::~Metadata() = default;
168

Callers

nothing calls this directly

Calls 6

StrXUTF8Class · 0.85
unicodeFormMethod · 0.80
getMethod · 0.45
parseMethod · 0.45
getDocumentMethod · 0.45
getAttributeMethod · 0.45

Tested by

no test coverage detected