Exemplo n.º 1
0
void ComplexBaseInputField::xmlData( QDomDocument &document, QDomElement &parent )
{
  QDomElement element = document.createElement( mName );

  XSD::Element::List elements = mType->elements();
  XSD::Element::List::ConstIterator elemIt;
  for ( elemIt = elements.constBegin(); elemIt != elements.constEnd(); ++elemIt ) {
    InputField *field = childField( (*elemIt).name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: No child found" );
    } else {
      field->xmlData( document, element );
    }
  }

  XSD::Attribute::List attributes = mType->attributes();
  XSD::Attribute::List::ConstIterator attrIt;
  for ( attrIt = attributes.constBegin(); attrIt != attributes.constEnd(); ++attrIt ) {
    InputField *field = childField( (*attrIt).name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: No child found" );
    } else {
      element.setAttribute( field->name(), field->data() );
    }
  }

  parent.appendChild( element );
}
Exemplo n.º 2
0
void ComplexBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "ComplexBaseInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
    return;
  }

  // elements
  if ( mType->isArray() ) {
    InputField *field = childField( "item" );
    field->setXMLData( element );
  } else {
    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
      QDomElement child = node.toElement();
      if ( !child.isNull() ) {
        InputField *field = childField( child.tagName() );
        if ( !field ) {
          qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
        } else {
          field->setXMLData( child );
        }
      }

      node = node.nextSibling();
    }
  }

  // attributes
  QDomNamedNodeMap nodes = element.attributes();
  for ( int i = 0; i < nodes.count(); ++i ) {
    QDomNode node = nodes.item( i );
    QDomAttr attr = node.toAttr();

    InputField *field = childField( attr.name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( attr.name() ) );
    } else {
      field->setData( attr.value() );
    }
  }
}
Exemplo n.º 3
0
void SimpleBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "SimpleBaseInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
    return;
  }

  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = childField( element.tagName() );
    if ( !field ) {
      qDebug( "SimpleBaseInputField: Child field %s does not exists", element.tagName().latin1() );
    } else {
      field->setXMLData( element );
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
  }
}
Exemplo n.º 4
0
void PageInputField::setXMLData( const QDomElement &element )
{
    if ( mName != element.tagName() ) {
        qDebug( "PageInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
        return;
    }

    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
        QDomElement child = node.toElement();
        if ( !child.isNull() ) {
            InputField *field = childField( child.tagName() );
            if ( !field ) {
                qDebug( "PageInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
            } else {
                field->setXMLData( child );
            }
        }

        node = node.nextSibling();
    }
}