Ejemplo n.º 1
0
	//--------------------------------------------------------------------
	bool RawUnknownElementHandler::elementBegin( const ParserChar* elementName, const xmlChar** attributes )
	{
		prepareToAddContents();

		mRawData.append( "<" );
		mRawData.append( elementName );
		mOpenTags.push( OpenTag() );
		/* OpenTag& currentOpenTag = mOpenTags.top(); */ /* UNUSED */

		if ( attributes )
		{
			const xmlChar** currentAttribute = attributes;
			while ( *currentAttribute )
			{
				const xmlChar* attributeName = *currentAttribute;
				currentAttribute++;
				if ( !currentAttribute )
				{
					// should never occur, but we want to make sure
					break;
				}
				const xmlChar* attributeValue = *currentAttribute;

				mRawData.append( " " );
				mRawData.append( attributeName );
				mRawData.append( "=\"" );
				mRawData.append( attributeValue );
				mRawData.append( "\"" );

				currentAttribute++;
			}
		}
		return true;
	}
Ejemplo n.º 2
0
	bool TcxFileWriter::StartLap(uint64_t timeMS)
	{
		XmlKeyValueList attributes;
		XmlKeyValuePair attribute;

		attribute.key = "StartTime";
		attribute.value = FormatTimeMS(timeMS);
		attributes.push_back(attribute);

		return OpenTag(TCX_TAG_NAME_LAP, attributes);
	}
Ejemplo n.º 3
0
	bool TcxFileWriter::StartActivity(const std::string& description)
	{
		XmlKeyValueList attributes;
		XmlKeyValuePair attribute;

		attribute.key = "Sport";
		attribute.value = description;
		attributes.push_back(attribute);

		return OpenTag(TCX_TAG_NAME_ACTIVITY, attributes);
	}
    //---------------------------------------------------------------
    TagCloser StreamWriter::openElement ( const String & name )
    {
        prepareToAddContents();
        appendNewLine();
        addWhiteSpace ( mLevel * mIndent );
        mLevel++;
        appendChar ( '<' );
        appendNCNameString ( name );
		ElementIndexType nextElementIndex = mNextElementIndex++;
        mOpenTags.push_back( OpenTag ( &name, nextElementIndex ) );

        return TagCloser ( this, nextElementIndex );
    }
Ejemplo n.º 5
0
	bool TcxFileWriter::StorePosition(double lat, double lon)
	{
		if (CurrentTag().compare(TCX_TAG_NAME_TRACKPOINT) != 0)
			return false;
		if (OpenTag(TCX_TAG_NAME_POSITION))
		{
			WriteTagAndValue(TCX_TAG_NAME_LATITUDE, lat);
			WriteTagAndValue(TCX_TAG_NAME_LONGITUDE, lon);
			CloseTag();
			return true;
		}
		return false;
	}
Ejemplo n.º 6
0
	bool TcxFileWriter::CreateFile(const std::string& fileName)
	{
		bool result = false;

		if (XmlFileWriter::CreateFile(fileName))
		{
			XmlKeyValueList attributes;
			XmlKeyValuePair attribute;

			attribute.key = "xmlns";
			attribute.value = "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2";
			attributes.push_back(attribute);

			attribute.key = "xmlns:xsd";
			attribute.value = "http://www.w3.org/2001/XMLSchema";
			attributes.push_back(attribute);
			
			attribute.key = "xmlns:xsi";
			attribute.value = "http://www.w3.org/2001/XMLSchema-instance";
			attributes.push_back(attribute);
			
			attribute.key = "xmlns:tc2";
			attribute.value = "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2";
			attributes.push_back(attribute);

			attribute.key = "targetNamespace";
			attribute.value = "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2";
			attributes.push_back(attribute);
			
			attribute.key = "elementFormDefault";
			attribute.value = "qualified";
			attributes.push_back(attribute);
			
			result  = OpenTag("TrainingCenterDatabase", attributes, true);
			result &= OpenTag(TCX_TAG_NAME_ACTIVITIES);
		}
		return result;
	}
Ejemplo n.º 7
0
NS_IMETHODIMP 
XULContentSinkImpl::HandleStartElement(const PRUnichar *aName, 
                                       const PRUnichar **aAtts,
                                       PRUint32 aAttsCount, 
                                       PRInt32 aIndex, 
                                       PRUint32 aLineNumber)
{ 
  // XXX Hopefully the parser will flag this before we get here. If
  // we're in the epilog, there should be no new elements
  NS_PRECONDITION(mState != eInEpilog, "tag in XUL doc epilog");
  NS_PRECONDITION(aIndex >= -1, "Bogus aIndex");
  NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount");
  // Adjust aAttsCount so it's the actual number of attributes
  aAttsCount /= 2;
  
  if (mState == eInEpilog)
      return NS_ERROR_UNEXPECTED;

  if (mState != eInScript) {
      FlushText();
  }

  PRInt32 nameSpaceID;
  nsCOMPtr<nsIAtom> prefix, localName;
  nsContentUtils::SplitExpatName(aName, getter_AddRefs(prefix),
                                 getter_AddRefs(localName), &nameSpaceID);

  nsCOMPtr<nsINodeInfo> nodeInfo;
  nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
                                           nsIDOMNode::ELEMENT_NODE);
  NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
  
  nsresult rv = NS_OK;
  switch (mState) {
  case eInProlog:
      // We're the root document element
      rv = OpenRoot(aAtts, aAttsCount, nodeInfo);
      break;

  case eInDocumentElement:
      rv = OpenTag(aAtts, aAttsCount, aLineNumber, nodeInfo);
      break;

  case eInEpilog:
  case eInScript:
      PR_LOG(gLog, PR_LOG_WARNING,
             ("xul: warning: unexpected tags in epilog at line %d",
             aLineNumber));
      rv = NS_ERROR_UNEXPECTED; // XXX
      break;
  }

  // Set the ID attribute atom on the node info object for this node
  if (aIndex != -1 && NS_SUCCEEDED(rv)) {
    nsCOMPtr<nsIAtom> IDAttr = do_GetAtom(aAtts[aIndex]);

    if (IDAttr) {
      nodeInfo->SetIDAttributeAtom(IDAttr);
    }
  }

  return rv;
}
Ejemplo n.º 8
0
	bool TcxFileWriter::StartTrackpoint()
	{
		return OpenTag(TCX_TAG_NAME_TRACKPOINT);
	}
Ejemplo n.º 9
0
	bool TcxFileWriter::StartTrack()
	{
		return OpenTag(TCX_TAG_NAME_TRACK);
	}