Пример #1
0
		void startElement(
			const XMLCh* namespaceURI, 
			const XMLCh* lName, 
			const XMLCh* qName, 
			const xercesc::Attributes& attrs)
		{

			// Update the information about the state of the current element (tracks ancestor attributes)
			outer.lock()->setElementState( ElementState(outer.lock()->getElementState(), attrs ));

			// Stash new URIs in xsi:schemaLocation attributes if desired
			if (loader->useSchemaLocationAttributes()) 
			{
				std::string schemaLocations = to_string(attrs.getValue(XS(XMLConstants::XMLSchemaInstanceNamespace),XS("schemaLocation")));
				if (!schemaLocations.empty()) 
				{
					//logger.debug("Processing schema locations: " + schemaLocations);
					//std::string[] fields = schemaLocations.trim().split("\\s+");
					//for (int i=1; i<fields.length; i=i+2) 
					{
						//try 
						//{
						//	Poco::URI uri = getBaseURISAXResolver().getBaseURI().resolve(Poco::URI(fields[i]));
						//	logger.debug("Working on: " + uri);
						//	loader.stashURI(uri);
						//}
						//catch (URISyntaxException e) 
						//{
						//	logger.warn("Ignoring malformed XSI schemaLocation URI in: " + schemaLocations);
						//}
						//catch (XBRLException e) 
						//{
						//	logger.warn("A problem occurred when stashing the schemaLocation URI: " + fields[i]);
						//}
						//catch (XMLBaseException e) 
						//{
						//	logger.warn("A problem occurred when getting the base URI so schemaLocation URIs were not stashed from: " + schemaLocations);
						//}
					}
				}
			}

			// Identify the fragments
			for (const std::shared_ptr<Identifier>& identifier : identifiers) 
			{
				try 
				{
					identifier->startElement(namespaceURI, lName, qName, attrs);
					if (loader->isBuildingAFragment()) 
					{
						if (loader->getFragment().isNewFragment()) 
						{
							break;
						}
					}
				}
				catch (XBRLException e) 
				{
					//	logger.error(this->getURI() + " : " + e.getMessage());
					throw xercesc::SAXException(strcat("Fragment identification failed. ", + e.getMessage().c_str()));
				}
			}

			if (! loader->isBuildingAFragment()) 
			{
				throw xercesc::SAXException("Some element has not been placed in a fragment.");
			}

			// Insert the current element into the fragment being built
			try 
			{
				Fragment fragment = loader->getFragment();
				//if (fragment == NULL) throw xercesc::SAXException("A fragment should be being built.");
				Builder builder = fragment.getBuilder();
				//if (builder == null) throw xercesc::SAXException("A fragment that is being built needs a builder.");
				builder.appendElement(namespaceURI, lName, qName, attrs);

				// Hardwire XLink resource language code inheritance to
				// improve query performance based on language selections.
				if (attrs.getIndex(XS(XMLConstants::XLinkNamespace),XS("type")) > -1) 
				{
					//try 
					//{
					std::shared_ptr<DOMElement> element = fragment.getDataRootElement();
					if (!element->hasAttributeNS(XS(XMLConstants::XMLNamespace),XS("lang"))) 
					{
						std::string code = outer.lock()->getElementState().getLanguageCode();
						//if (code != null) 
						//{
						element->setAttribute(XS("xml:lang"),XS(code));
						//}
					}
					//}
					//catch (Throwable t) 
					//{
					//	logger.info("bugger");
					//}
				}

			}
			catch (XBRLException e) 
			{
				//	logger.error(this->getURI() + " : " + e.getMessage());
				throw xercesc::SAXException(strcat("The element could not be appended to the fragment.",e.getMessage().c_str()));
			}

		}
Пример #2
0
 void _resizeEvent()
 {
   for( int i=0; i < StateCount; i++ )
       _updateTexture( ElementState(i) );
 }