TupStoryboardExportPackage::TupStoryboardExportPackage(const QString &title, const QString &topics, const QString &description, const QList<int> sceneIndexes): QDomDocument()
{
    QDomElement root = createElement("project_storyboard");
    root.setAttribute("version", "0");
    appendChild(root);
    
    QString indexes = "";
    for (int i=0; i < sceneIndexes.size(); i++)
         indexes += QString::number(sceneIndexes.at(i)) + ","; 

    indexes.remove(indexes.length() - 1, 1);

    QDomElement story = createElement("storyboard");
    story.setAttribute("scenes", indexes);

    QDomText titleDom = createTextNode(title);
    QDomText topicDom = createTextNode(topics);
    QDomText descDom = createTextNode(description);

    story.appendChild(createElement("title")).appendChild(titleDom);
    story.appendChild(createElement("topics")).appendChild(topicDom);
    story.appendChild(createElement("description")).appendChild(descDom);
    
    root.appendChild(story);
}
RegisterUser::RegisterUser(const QString &login, const QString &email) : QDomDocument()
{
	QDomElement root = createElement("registeruser");
	
	root.appendChild( createElement("login") ).appendChild(createTextNode(login));
	root.appendChild( createElement("email") ).appendChild(createTextNode(email));
	
	appendChild(root);
}
void ResultDocument::setError(int c, const QString &m) {

	QDomElement errorResult = createElement("error_result");
	appendChild(errorResult);
	QDomElement errorCode = createElement("error_code");
	errorResult.appendChild(errorCode);
	QDomText code = createTextNode(QString::number(c));
	errorCode.appendChild(code);
	
	QDomElement errorMessage = createElement("error_message");
	errorResult.appendChild(errorMessage);
	QDomText message = createTextNode(m);
	errorMessage.appendChild(message);
}
void ProjectFile::SetAttribute(QString parentTag, QString childTag, QString attribute, QString value)
{
	QDomElement parentTagElement = documentElement().namedItem(parentTag).toElement();
	if (parentTagElement.isNull())
	{
		parentTagElement = createElement(parentTag);
		documentElement().appendChild(parentTagElement);
	}

	QDomElement childTagElement = parentTagElement.namedItem(childTag).toElement();
	if (childTagElement.isNull())
	{
		childTagElement = createElement(childTag);
		parentTagElement.appendChild(childTagElement);
	}

	QDomNode attributeNode = childTagElement.namedItem(value);
	if (!attributeNode.isNull())
	{
		childTagElement.removeChild(attributeNode);
	}

	QDomElement attributeElement = createElement(attribute);
	attributeElement.appendChild(createTextNode(value));
	childTagElement.appendChild(attributeElement);

	SaveProject();
}
RemoveUser::RemoveUser(const QString& login): QDomDocument(), d(new Private)
{
	QDomElement root = createElement( "removeuser" );
	root.setAttribute( "version",  "0" );
	appendChild(root);
	d->login = createTextNode(login);
	root.appendChild(createElement("login")).appendChild(d->login);
}
QueryProject::QueryProject(const QString & name): QDomDocument() , d(new Private)
{
	QDomElement root = createElement( "queryproject" );
	root.setAttribute( "version",  "0" );
	appendChild(root);
	d->name = createTextNode(name);
	root.appendChild(createElement("name")).appendChild(d->name);
}
void ListProjects::requestAll()
{
	QDomElement option = createElement("option");
	QDomText text = createTextNode("all");
	
	option.appendChild(text);
	
	documentElement().appendChild(option);
}
TupImageExportPackage::TupImageExportPackage(int frameIndex, int sceneIndex, const QString &title, const QString &topics, const QString &description): QDomDocument()
{
    QDomElement root = createElement("project_image");
    root.setAttribute("version", "0");
    appendChild(root);
    
    QDomElement image = createElement("image");
    image.setAttribute("scene", sceneIndex);
    image.setAttribute("frame", frameIndex);

    QDomText titleDom = createTextNode(title);
    QDomText topicDom = createTextNode(topics);
    QDomText descDom = createTextNode(description);

    image.appendChild(createElement("title")).appendChild(titleDom);
    image.appendChild(createElement("topics")).appendChild(topicDom);
    image.appendChild(createElement("description")).appendChild(descDom);
    
    root.appendChild(image);
}
Beispiel #9
0
Error::Error(const QString &message, Level level)
    : QDomDocument()
{
    QDomElement root = createElement ("error");
    root.setAttribute("version", "0");
    appendChild(root);
    
    m_message = createElement("message");
    root.appendChild(m_message);
    m_message.appendChild(createTextNode(message));
    m_message.setAttribute("level", level);
}
TEST_F(DocumentMarkerControllerTest, NodeWillBeRemovedMarkedByReplaceChild)
{
    setBodyInnerHTML("<b><i>foo</i></b>");
    {
        RefPtrWillBeRawPtr<Element> parent = toElement(document().body()->firstChild()->firstChild());
        markNodeContents(parent.get());
        EXPECT_EQ(1u, markerController().markers().size());
        parent->replaceChild(createTextNode("bar").get(), parent->firstChild());
    }
    // No more reference to marked node.
    Heap::collectAllGarbage();
    EXPECT_EQ(0u, markerController().markers().size());
}
void ProjectFile::SetAttribute(QString attribute, QString value)
{
	QDomNode attributeNode = documentElement().namedItem(attribute);
	if (!attributeNode.isNull())
	{
		documentElement().removeChild(attributeNode);
	}

	QDomElement attributeElement = createElement(attribute);
	attributeElement.appendChild(createTextNode(value));
	documentElement().appendChild(attributeElement);

	SaveProject();
}
TEST_F(DocumentMarkerControllerTest, NodeWillBeRemovedMarkedByNormalize)
{
    setBodyInnerHTML("<b><i>foo</i></b>");
    {
        Element* parent = toElement(document().body()->firstChild()->firstChild());
        parent->appendChild(createTextNode("bar"));
        markNodeContents(parent);
        EXPECT_EQ(2u, markerController().markers().size());
        parent->normalize();
    }
    // No more reference to marked node.
    ThreadHeap::collectAllGarbage();
    EXPECT_EQ(1u, markerController().markers().size());
}
void ProjectFile::FileModified()
{
	lastModified = QDateTime::currentDateTime();

	QDomNode attributeNode = documentElement().namedItem(ATTR_LASTSAVE);
	if (!attributeNode.isNull())
	{
		documentElement().removeChild(attributeNode);
	}

	QDomElement attributeElement = createElement(ATTR_LASTSAVE);
	attributeElement.appendChild(createTextNode(lastModified.toString(Qt::ISODate)));
	documentElement().appendChild(attributeElement);
}
Beispiel #14
0
void DocumentXML::ajouterSommet(SommetColore* sommet, QString id)
{
    QDomElement qElmt=ownerDocument().createElement("Sommet");
    XMLElementSommet *elmt=new XMLElementSommet(sommet,qElmt,graphe);
    QDomElement listeDomSommets = documentElement().firstChildElement("Sommets");
    listeDomSommets.appendChild(*elmt);

    //On fixe la valeur affichée
    elmt->setAttribute(QString("id"),id);

    QDomElement couleurElmt=createElement("Couleur");
    elmt->appendChild(couleurElmt);
    string couleur="#"+sommet->getCouleur();
    couleurElmt.appendChild(createTextNode(QString(couleur.c_str())));
}
bool ProjectFile::AddSubdomain(QString newName)
{
	QDomElement currentSubdomain = documentElement().firstChildElement(TAG_SUB_DOMAIN);
	while (!currentSubdomain.isNull())
	{
		QDomElement nameElement = currentSubdomain.namedItem(ATTR_NAME).toElement();
		if (nameElement.text() == newName)
		{
			if (!WarnSubdomainExists(newName))
			{
				return false;
			} else {
				documentElement().removeChild(currentSubdomain);
				break;
			}
		}

		currentSubdomain = currentSubdomain.nextSiblingElement(TAG_SUB_DOMAIN);
//		{
//			QDomNode attributeNode = currentSubdomain.namedItem(attribute);
//			if (!attributeNode.isNull())
//			{
//				currentSubdomain.removeChild(attributeNode);
//			}

//			QDomElement attributeElement = createElement(attribute);
//			attributeElement.appendChild(createTextNode(value));
//			currentSubdomain.appendChild(attributeElement);
//			break;
//		}
	}

	QDomElement newSubdomain = createElement(TAG_SUB_DOMAIN);
	QDomElement newSubdomainName = createElement(ATTR_NAME);
	documentElement().appendChild(newSubdomain);
	newSubdomain.appendChild(newSubdomainName);
	newSubdomainName.appendChild(createTextNode(newName));

	SaveProject();

	return true;
}
void ProjectFile::SetAttributeSubdomain(QString subdomainName, QString attribute, QString value)
{
	QDomElement currentSubdomain = documentElement().firstChildElement(TAG_SUB_DOMAIN);
	while (!currentSubdomain.isNull())
	{
		QDomElement nameElement = currentSubdomain.namedItem(ATTR_NAME).toElement();
		if (nameElement.text() == subdomainName)
		{
			QDomNode attributeNode = currentSubdomain.namedItem(attribute);
			if (!attributeNode.isNull())
			{
				currentSubdomain.removeChild(attributeNode);
			}

			QDomElement attributeElement = createElement(attribute);
			attributeElement.appendChild(createTextNode(value));
			currentSubdomain.appendChild(attributeElement);
			break;
		}
		currentSubdomain = currentSubdomain.nextSiblingElement(TAG_SUB_DOMAIN);
	}

	SaveProject();
}
Beispiel #17
0
TupNewProjectPackage::TupNewProjectPackage(const QString & name, const QString & author, const QString & description, const QString & bgcolor, const QString & dimension, const QString & fps): QDomDocument(), k(new Private)
{
    QDomElement root = createElement("project_new");
    root.setAttribute("version", "0");
    
    k->name = createTextNode(name);
    k->author = createTextNode(author);
    k->description = createTextNode(description);
    k->bgcolor = createTextNode(bgcolor);
    k->dimension = createTextNode(dimension);
    k->fps = createTextNode(fps);
    
    root.appendChild(createElement("name")).appendChild(k->name);
    root.appendChild(createElement("author")).appendChild(k->author);
    root.appendChild(createElement("description")).appendChild(k->description);
    root.appendChild(createElement("bgcolor")).appendChild(k->bgcolor);
    root.appendChild(createElement("dimension")).appendChild(k->dimension);
    root.appendChild(createElement("fps")).appendChild(k->fps);

    appendChild(root);
}
Beispiel #18
0
void Scene::create()
{
    _oneSidedProgram = new osg::Program;
    _oneSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::VERTEX, "data/diffuse_directional1_vs.glsl"));
    _oneSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::FRAGMENT, "data/diffuse_directional1_fs.glsl"));

    _twoSidedProgram = new osg::Program;
    _twoSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::VERTEX, "data/diffuse_directional2_vs.glsl"));
    _twoSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::FRAGMENT, "data/diffuse_directional2_fs.glsl"));

    _instancedProgram = new osg::Program;
    _instancedProgram->addShader(osgDB::readShaderFile(osg::Shader::VERTEX, "data/diffuse_billboard_instanced_vs.glsl"));
    _instancedProgram->addShader(osgDB::readShaderFile(osg::Shader::FRAGMENT, "data/diffuse_billboard_instanced_fs.glsl"));

    createPolyhedronNode();
    createVertexNode();
    createTextNode();

    onPolyhedronChanged();
    onLightModelChanged();

    osg::ref_ptr<osgGA::LambdaEventHandler> eventHandler = new osgGA::LambdaEventHandler;
    eventHandler->onKeyDown([&](const osgGA::GUIEventAdapter& ea) {
        auto key = ea.getKey();
        auto num = key - osgGA::GUIEventAdapter::KEY_0;
        if (0 <= num && num <= 9)
        {
            _faces ^= osgKaleido::PolyhedronGeometry::FaceMaskFromSides(wild::mod(num-1, 10) + 3);
            onFaceMaskChanged();
            return true;
        }
        switch (key)
        {
        case osgGA::GUIEventAdapter::KEY_V:
        {
            _vgeode->setNodeMask(~_vgeode->getNodeMask());
            return true;
        }
        case osgGA::GUIEventAdapter::KEY_L:
        {
            _twoSided = !_twoSided;
            onLightModelChanged();
            return true;
        }
        case osgGA::GUIEventAdapter::KEY_Right:
        {
            _faces = osgKaleido::PolyhedronGeometry::All;
            _index++;
            onPolyhedronChanged();
            return true;
        }
        case osgGA::GUIEventAdapter::KEY_Left:
        {
            _faces = osgKaleido::PolyhedronGeometry::All;
            _index--;
            onPolyhedronChanged();
            return true;
        }
        default:
            return false;
        }
    });

    _viewer->addEventHandler(eventHandler);
}
Beispiel #19
0
  void QueryDocument::parseQuery ( XProcessor& xproc, bool isQuery )
  {
    ElementRef cookiesList = queryElement.getDocument().createElement ( queryElement, xem_web.cookies() );
    queryElement.appendLastChild ( cookiesList );

    ElementRef headersList = queryElement.getDocument().createElement ( queryElement, xem_web.headers() );
    queryElement.appendLastChild ( headersList );

    QParseState state = QParseState_HeadLine;
    String accu = "";
    String method;
    ElementRef headerElement(*this);
    ElementRef responseElement(*this);
    ElementRef urlElement(*this);
    ElementRef urlParams(*this);
    ElementRef urlParam(*this);
    ElementRef cookieElement(*this);

    __ui64 contentLength = 0;
    bool transferEncodingChunked = false;

#define Invalid() throwException(Exception, "Invalid character %d at state %d\n", r, state );

    while ( state != QParseState_FinishedHTTPHeader && !reader.isFinished())
      {
        int r = reader.getNextChar();
        if ( r >= 0x80 )
          {
            throwException ( Exception, "Invalid char %d\n", r );
          }
        // Log_QParse ( "state=%d, r=%x (%d, %c)\n", state, r, r, r );
        switch ( state )
        {
        case QParseState_HeadLine:
          if ( r == ' ' )
            {
              Log_QParse ( "Method : '%s'\n", accu.c_str() );
              if ( isQuery )
                {
                  if ( accu == "GET" || accu == "POST" )
                    {
                      ElementRef methodElement = addTextualElement ( queryElement, xem_web.method(), accu );
                      method = methodElement.getText();
                      state = QParseState_URLStart;
                      accu = "";
                      continue;
                    }
                  else
                    Invalid();
                }
              else
                {
                  if ( accu == "HTTP/1.1" )
                    {
                      Log_QParse ( "Got a Response, protocol=%s\n", accu.c_str() );
                      addTextualElement ( queryElement, xem_web.protocol(), accu );
                      accu = "";
                      state = QParseState_ResponseCode;
                      responseElement = createElement ( headersList, xem_web.response() );
                      headersList.appendLastChild ( responseElement );
                    }
                  else
                    {
                      Invalid();
                    }
                }
            }
          else if ( r == '\r' || r == '\n' )
            {
              Invalid();
            }
          accu.appendUtf8(r);
          break;
        case QParseState_URLStart:
          if ( r == '/' )
            {
              state = QParseState_URL;
              continue;
            }
          Invalid();
          break;
        case QParseState_URL:
          if ( r == ' ' || r == '?' )
            {
              Log_QParse ( "Url : '%s'\n", accu.c_str() );
              urlElement = createElement ( queryElement, xem_web.url() );
              queryElement.appendLastChild ( urlElement );
              addTextualElement ( urlElement, xem_web.base(), accu );

              accu = "";
              if ( r == ' ' )
                {
                  state = QParseState_Protocol;
                }
              else
                {
                  state = QParseState_URLParam;
                }
              continue;
            }
          else if ( r == '?' )
            {
              Invalid();
            }
          else if ( r == '\r' || r == '\n' )
            {
              Invalid();
            }
          else if ( r == '%' )
            {
              Invalid ();
            }
          accu.appendUtf8(r);
          break;
        case QParseState_URLParam:
          if ( r == '\n' || r == '%' || r == '\r' )
            {
              Invalid();
            }
          else if ( r == '=' || r == ' ' || r == '&' )
            {
              if ( ! urlParams )
                {
                  urlParams = createElement ( urlElement, xem_web.parameters() );
                  urlElement.appendLastChild ( urlParams );
                }
              Log_QParse ( "Param : '%s'\n", accu.c_str() );
              urlParam = createElement ( urlParams, xem_web.param() );
              urlParams.appendLastChild ( urlParam );
              urlParam.addAttr ( xem_web.name(), accu );
              accu = "";
              if ( r == '=' )
                state = QParseState_URLParamValue;
              else if ( r == '&' )
                state = QParseState_URLParam;
              else if ( r == ' ' )
                state = QParseState_Protocol;
              else
                { Invalid(); }
              continue;
            }
          accu.appendUtf8(r);
          break;
        case QParseState_URLParamValue:
          if ( r == '&' || r == ' ')
            {
              Log_QParse ( "Param Value : '%s'\n", accu.c_str() );
              ElementRef valueNode = createTextNode ( urlParam, accu );
              urlParam.appendLastChild ( valueNode );
              urlParam = ElementRef(*this);
              accu = "";
              if ( r == '&' )
                state = QParseState_URLParam;
              else
                state = QParseState_Protocol;
              continue;
            }
          accu.appendUtf8(r);
          break;
        case QParseState_Protocol:
          if ( r == ' ' )
            {
              Invalid();
            }
          else if ( r == '\r' )
            {
              continue;
            }
          else if ( r == '\n' )
            {
              Log_QParse ( "Protocol = '%s'\n", accu.c_str() );
              addTextualElement ( queryElement, xem_web.protocol(), accu );
              accu = "";
              state = QParseState_BeginLine;
              continue;
            }
          accu.appendUtf8(r);
          break;
        case QParseState_ResponseCode:
          if ( r == ' ' )
            {
              Log_QParse ( "ResponseCode : %s\n", accu.c_str() );
              responseElement.addAttr ( xem_web.response_code(), accu );
              accu = "";
              state = QParseState_ResponseString;
              continue;
            }
          if ( '0' <= r && r <= '9' )
            {
              accu.appendUtf8(r);
              continue;
            }
          Invalid();
          break;
        case QParseState_ResponseString:
          if ( r == '\r' )
            continue;
          else if ( r == '\n' )
            {
              Log_QParse ( "ResponseString : %s\n", accu.c_str() );
              responseElement.addAttr ( xem_web.response_string(), accu );
              accu = "";
              state = QParseState_BeginLine;
              continue;
            }
          accu.appendUtf8(r);
          break;
        case QParseState_BeginLine:
          if ( r == '\r' )
            continue;
          else if ( r == '\n' )
            {
              state = QParseState_FinishedHTTPHeader;
              break;
            }
          else if ( r == ' ' )
            {
              Invalid();
            }
          accu.appendUtf8(r);
          state = QParseState_FieldName;
          continue;
        case QParseState_FieldName:
          if ( r == ':' )
            {
              Log_QParse ( "Field : '%s'\n", accu.c_str() );
              if ( accu == "Cookie" )
                {
                  accu = "";
                  state = QParseState_CookieStart;
                  continue;
                }
              headerElement = createElement ( headersList, xem_web.param() );
              headersList.appendLastChild ( headerElement );
              headerElement.addAttr ( xem_web.name(), accu );
              accu = "";
              state = QParseState_PostFieldName;
              continue;
            }
          else if ( r == ' ' || r == '\n' || r == '\r' )
            {
               Invalid();
            }
          accu.appendUtf8(r);
          break;
        case QParseState_PostFieldName:
          if ( r == ' ' )
            {
              state = QParseState_Value;
              continue;
            }
          Invalid();
        case QParseState_Value:
          if ( r == '\r')
            continue;
          else if ( r == '\n' )
            {
              Log_QParse ( "Field value : '%s'\n", accu.c_str() );
              ElementRef valueNode = createTextNode ( headerElement, accu );
              headerElement.appendLastChild ( valueNode );
              String fieldName = headerElement.getAttr(xem_web.name());
#ifdef __XEM_WEBSERVER_QUERYDOCUMENT_HAS_HEADERFIELDSMAP
              headerFieldsMap[fieldName] = valueNode.getText();
#endif
              if ( fieldName == "Content-Length" )
                {
                  contentLength = accu.toUI64();
                  Log_QParse ( "ContentLength : %llu\n", contentLength );
                }
              else if ( fieldName == "Transfer-Encoding" && accu == "chunked" )
                {
                  Log_QParse ( "TransferEncoding chuncked !\n" );
                  transferEncodingChunked = true;
                }
              headerElement = ElementRef(*this);
              accu = "";
              state = QParseState_BeginLine;
              continue;
            }
          accu.appendUtf8(r);
          break;
        case QParseState_CookieStart:
          if ( r == ' ' )
            continue;
          accu.appendUtf8(r);
          state = QParseState_CookieName;
          break;
        case QParseState_CookieName:
          if ( r == '=' )
            {
              Log_QParse ( "Cookie name : '%s'\n", accu.c_str() );
              cookieElement = createElement ( cookiesList, xem_web.cookie() );
              cookieElement.addAttr ( xem_web.name(), accu );
              cookiesList.appendLastChild ( cookieElement );

              accu = "";
              state = QParseState_CookieValue;
              continue;
            }
          accu.appendUtf8(r);
          break;
        case QParseState_CookieValue:
          if ( r == '\r' )
            continue;
          if ( r == ';' || r == '\n' )
            {
              Log_QParse ( "Cookie value : '%s'\n", accu.c_str() );
              ElementRef cookieValueNode = createTextNode ( cookieElement, accu );
              cookieElement.appendLastChild ( cookieValueNode );

              accu = "";
              if ( r == ';' )
                state = QParseState_CookieStart;
              else
                state = QParseState_BeginLine;
              continue;
            }
          accu.appendUtf8(r);
          break;
        default:
          Bug ( "Case %d Not implemented !\n", state );
        }
      }
    if ( state != QParseState_FinishedHTTPHeader )
      {
        throwException ( Exception, "HTTP reader not finished ! state=%d\n", state );
      }
    if ( contentLength || transferEncodingChunked )
      {
        if ( !isQuery || method == "POST" )
          {
            ElementRef content = createElement ( queryElement, xem_web.content() );
            queryElement.appendLastChild ( content );
            BlobRef blob = content.addBlob(xem_web.blob_contents());
            if ( contentLength )
              parseToBlob(blob, contentLength);
            else
              parseChunkedToBlob(blob);
          }
        else
          {
            throwException ( Exception, "Invalid content-length with method = %s\n", method.c_str() );
          }
      }
  }
Beispiel #20
0
bool Xsd::GetEnumXSD( HTTPRequest *pRequest, QString sEnumName )
{
    if (sEnumName.isEmpty())
        return false;

    // ----------------------------------------------------------------------
    // sEnumName needs to be in class.enum format
    // ----------------------------------------------------------------------

    if (sEnumName.count('.') != 1 )
        return false;

    QStringList lstTypeParts = sEnumName.split( '.' );

    // ----------------------------------------------------------------------
    // Create Parent object so we can get to its metaObject
    // ----------------------------------------------------------------------

    QString sParentFQN = "DTC::" + lstTypeParts[0];

    int nParentId = QMetaType::type( sParentFQN.toUtf8() );

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QObject *pParentClass = (QObject *)QMetaType::construct( nParentId );
#else
    QObject *pParentClass = (QObject *)QMetaType::create( nParentId );
#endif

    const QMetaObject *pMetaObject = pParentClass->metaObject();

    QMetaType::destroy( nParentId, pParentClass );

    // ----------------------------------------------------------------------
    // Now look up enum
    // ----------------------------------------------------------------------

    int nEnumIdx = pMetaObject->indexOfEnumerator( lstTypeParts[1].toUtf8() );

    if (nEnumIdx < 0 )
        return false;

    QMetaEnum metaEnum = pMetaObject->enumerator( nEnumIdx );

    // ----------------------------------------------------------------------
    // render xsd for this enum
    //
    //    <xs:simpleType name="RecordingInfo.RecordingDupMethodEnum">
    //        <xs:restriction base="xs:string">
    //            <xs:enumeration value="kDupCheckNone">
    //                <xs:annotation>
    //                    <xs:appinfo>
    //                        <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1</EnumerationValue>
    //                    </xs:appinfo>
    //                </xs:annotation>
    //            </xs:enumeration>
    //            <xs:enumeration value="kDupCheckSub">
    //                <xs:annotation>
    //                    <xs:appinfo>
    //                        <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">2</EnumerationValue>
    //                    </xs:appinfo>
    //                </xs:annotation>
    //            </xs:enumeration>
    //        </xs:restriction>
    //    </xs:simpleType>
    //
    //    <xs:element name="RecordingInfo.RecordingDupMethodEnum" type="tns:RecordingInfo.RecordingDupMethodEnum" nillable="true"/>
    // ----------------------------------------------------------------------

    if (!pRequest->m_mapParams.contains( "raw" ))
    {
        appendChild( createProcessingInstruction( "xml-stylesheet",
                        "type=\"text/xsl\" href=\"/xslt/enum.xslt\"" ));
    }

    // ----------------------------------------------------------------------
    // Create xs:simpleType structure
    // ----------------------------------------------------------------------
    
    QDomElement oTypeNode     = createElement( "xs:simpleType"  );
    QDomElement oRestrictNode = createElement( "xs:restriction" );

    oTypeNode    .setAttribute( "name", sEnumName   );
    oRestrictNode.setAttribute( "base", "xs:string" );

    oTypeNode.appendChild( oRestrictNode  );

    for( int nIdx = 0; nIdx < metaEnum.keyCount(); nIdx++)
    {
        QDomElement oEnum = createElement( "xs:enumeration" );

        oEnum.setAttribute( "value", metaEnum.key( nIdx ));

        // ------------------------------------------------------------------
        // Add appInfo to store numerical value & translated text
        // ------------------------------------------------------------------

        QDomElement oAnn      = createElement( "xs:annotation"    );
        QDomElement oApp      = createElement( "xs:appinfo"       );
        QDomElement oEnumVal  = createElement( "EnumerationValue" );
        QDomElement oEnumDesc = createElement( "EnumerationDesc"  );

        oEnum.appendChild( oAnn      );
        oAnn .appendChild( oApp      );
        oApp .appendChild( oEnumVal  );
        oApp .appendChild( oEnumDesc );

        oEnumVal .appendChild( createTextNode( QString::number( metaEnum.value( nIdx ))));
        oEnumDesc.appendChild( createTextNode( QObject::tr( metaEnum.key( nIdx ), "Enums" )));

        oRestrictNode.appendChild( oEnum );
    }

    // ----------------------------------------------------------------------

    QDomElement oElementNode = createElement( "xs:element" );

    oElementNode.setAttribute( "name"    , sEnumName );
    oElementNode.setAttribute( "type"    , "tns:" + sEnumName );
    oElementNode.setAttribute( "nillable", "true" );

    // ----------------------------------------------------------------------
    // 
    // ----------------------------------------------------------------------

    QDomElement oRoot = CreateSchemaRoot();

    oRoot.appendChild( oTypeNode    );
    oRoot.appendChild( oElementNode );

    appendChild( oRoot );

    // ----------------------------------------------------------------------
    // Return xsd doc to caller
    // ----------------------------------------------------------------------

    QTextStream os( &(pRequest->m_response) );

    pRequest->m_eResponseType   = ResponseTypeXML;

    save( os, 0 );

    return true;
}
Beispiel #21
0
bool Xsd::RenderMapXSD( HTTPRequest   *pRequest, 
                        const QString &sClassName, 
                        bool           bCustomType )
{
    QString     sArrayName   = "MapOfString" + sClassName;
    QString     sMapItemName = pRequest->m_mapParams[ "name" ];
    QString     sType;

    if (sMapItemName.isEmpty())
        sMapItemName = sClassName;

    if (bCustomType)
        sType = "tns:" + sMapItemName;
    else
        sType = "xs:" + ConvertTypeToXSD( sMapItemName, false );

    QDomElement oRoot      = CreateSchemaRoot();

    // ------------------------------------------------------------------
    // Create xs:complexType structure
    // ------------------------------------------------------------------
    
    QDomElement oTypeNode = createElement( "xs:complexType" );
    QDomElement oSeqNode  = createElement( "xs:sequence"    );
    QDomElement oAnno     = createElement( "xs:annotation"  );
    QDomElement oAppInfo  = createElement( "xs:appinfo"     );

    QDomElement oNode = createElement( "IsDictionary" );
    oNode.setAttribute( "xmlns", "http://schemas.microsoft.com/2003/10/Serialization/" );
    oNode.appendChild( createTextNode( "true" ));

    oTypeNode.appendChild( oAnno    );
    oAnno    .appendChild( oAppInfo );
    oAppInfo .appendChild( oNode    );

    // -=>TODO: Add an xs:annotation node with class descriptions

    // ----------------------------------------------------------------------
    //  <xs:sequence>
    // ----------------------------------------------------------------------

    oTypeNode.setAttribute( "name", sArrayName );
    oTypeNode.appendChild( oSeqNode  );

    // ----------------------------------------------------------------------
    //    <xs:element minOccurs="0" maxOccurs="unbounded" name="KeyValueOfString<Type>">
    // ----------------------------------------------------------------------

    QDomElement oInnerNode = createElement( "xs:element" );

    oInnerNode.setAttribute( "name"      , sClassName  );
    oInnerNode.setAttribute( "maxOccurs" , "unbounded" );
    oInnerNode.setAttribute( "minOccurs" , "0"         );

    oSeqNode.appendChild( oInnerNode );

    // ----------------------------------------------------------------------
    //      <xs:complexType>
    // ----------------------------------------------------------------------
    oNode = createElement( "xs:complexType" );

    oInnerNode.appendChild( oNode );

    // ----------------------------------------------------------------------
    //        <xs:sequence>
    // ----------------------------------------------------------------------

    QDomElement oInnerSeq = createElement( "xs:sequence" );

    oNode.appendChild( oInnerSeq );

    // ----------------------------------------------------------------------
    //           <xs:element name="Key" nillable="true" type="xs:string" /> 
    // ----------------------------------------------------------------------

    oNode = createElement( "xs:element" );

    oNode.setAttribute( "type"      , "xs:string" );
    oNode.setAttribute( "nillable"  , "true" );
    oNode.setAttribute( "name"      , "Key" );

    oInnerSeq.appendChild( oNode  );

    // ----------------------------------------------------------------------
    //           <xs:element name="Value" nillable="true" type="<Type>"  /> 
    // ----------------------------------------------------------------------

    oNode = createElement( "xs:element" );

    oNode.setAttribute( "type"      , sType );
    oNode.setAttribute( "nillable"  , "true" );
    oNode.setAttribute( "name"      , "Value" );

    oInnerSeq.appendChild( oNode  );

    // ----------------------------------------------------------------------
    //<xs:element name="MapOfString<Type>" nillable="true" type="tns:MapOfString<Type>" /> 
    // ----------------------------------------------------------------------
    
    QDomElement oElementNode = createElement( "xs:element" );

    oElementNode.setAttribute( "type"    , "tns:" + sArrayName );
    oElementNode.setAttribute( "nillable", "true" );
    oElementNode.setAttribute( "name"    , sArrayName );

    // ----------------------------------------------------------------------
    // Build xml tree...
    // ----------------------------------------------------------------------

    appendChild( oRoot );

    if (bCustomType)
    {
        QDomElement oIncNode = createElement( "xs:include" );

        QString sBaseUri = "http://" + pRequest->m_mapHeaders[ "host" ] + pRequest->m_sResourceUrl + "?type=";

        oIncNode.setAttribute( "schemaLocation", sBaseUri + sClassName );

        oRoot.appendChild( oIncNode );
    }
    
    oRoot.appendChild( oTypeNode    );
    oRoot.appendChild( oElementNode );

    // ----------------------------------------------------------------------
    // Return xsd doc to caller
    // ----------------------------------------------------------------------

    QTextStream os( &(pRequest->m_response) );

    pRequest->m_eResponseType   = ResponseTypeXML;

    save( os, 0 );

    return true;

}