Example #1
0
DataSourceMetaData::DataSourceMetaData(MemoryBuffer & buffer)
{
    numVirtualFields = 0;
    buffer.read(numFieldsToIgnore);
    buffer.read(randomIsOk);
    buffer.read(isStoredFixedWidth);
    buffer.read(storedFixedSize);
    buffer.read(keyedSize);
    buffer.read(maxRecordSize);

    unsigned numFields;
    buffer.read(numFields);
    for (unsigned idx=0; idx < numFields; idx++)
    {
        byte flags;
        buffer.read(flags);
        if (flags == FVFFdataset)
            fields.append(*new DataSourceDatasetItem(flags, buffer));
        else if (flags == FVFFset)
            fields.append(*new DataSourceSetItem(flags, buffer));
        else
            fields.append(*new DataSourceMetaItem(flags, buffer));
        if (flags == FVFFvirtual)
            ++numVirtualFields;
    }
    gatherAttributes();
}
  virtual void startElement(const std::string& /* namespaceURI */,
                            const std::string& /* localName */,
                            const std::string& qName,
                            const SAX::Attributes<std::string>& atts)
  {
    if(sort_ == 0)
    {
      static const ValueRule rules[] = { { "select", false, ".", 0 },
                                         { "lang", false, 0, 0 },
                                         { "data-type", false, "text", 0 },
                                         { "order", false, "ascending", 0 },
                                         { "case-order", false, "upper-first", 0 },
                                         { 0, false, 0, 0 } };

      std::map<std::string, std::string> attr = gatherAttributes(qName, atts, rules);

      Arabica::XPath::XPathExpressionPtr<std::string> select, lang, datatype, order, caseorder;
      select = context_.xpath_expression(attr["select"]);
      datatype = context_.xpath_attribute_value_template(attr["data-type"]);
      order = context_.xpath_attribute_value_template(attr["order"]);
      caseorder = context_.xpath_attribute_value_template(attr["case-order"]);

      if(attr["lang"].length() != 0)
	std::cerr << "Sorry!  Don't support xsl:sort lang attribute yet" << std::endl;
 
      sort_ = new Sort(select,
                       lang, 
                       datatype, 
                       order,
                       caseorder);
      return;
    } // if(sort_ == 0)

    throw SAX::SAXException("xsl:sort can not contain elements");
  } // startElement
  virtual Copy* createContainer(const std::string& /* namespaceURI */,
                                const std::string& /* localName */,
                                const std::string& qName,
                                const SAX::Attributes<std::string>& atts)
  {
    static const ValueRule rules[] = { { "use-attribute-sets", false, 0, 0 },
                                       { 0, false, 0, 0 } };
    std::string sets = gatherAttributes(qName, atts, rules)["use-attribute-sets"];

    return new Copy(sets);
  } // createContainer
  virtual ProcessingInstruction* createContainer(const std::string& /* namespaceURI */,
                                                 const std::string& /* localName */,
                                                 const std::string& qName,
                                                 const SAX::Attributes<std::string>& atts)
  {
    static const ValueRule rules[] = { { "name", true, 0, 0 },
                                       { 0, false, 0, 0} };
    std::string name = gatherAttributes(qName, atts, rules)["name"];

    return new ProcessingInstruction(ItemContainerHandler<ProcessingInstruction>::context().xpath_attribute_value_template(name));
  } // createContainer
  virtual void startElement(const std::string& /* namespaceURI */,
                            const std::string& /* localName */,
                            const std::string& qName,
                            const SAX::Attributes<std::string>& atts)
  {
    if(copyOf_ == 0)
    {
      static const ValueRule rules[] = { { "select", true, 0, 0 },
                                         { 0, false, 0, 0 } };
      std::string select = gatherAttributes(qName, atts, rules)["select"];

      copyOf_ = new CopyOf(context_.xpath_expression(select));

      return;
    } // if(copyOf_ == 0)

    throw SAX::SAXException(qName + " can not contain elements");
  } // startElement
 void startStylesheet(const std::string& /* namespaceURI */,
                      const std::string& localName,
                      const std::string& qName,
                      const SAX::Attributes<std::string>& atts)
 {
   if(localName != "stylesheet" && localName != "transform")
     throw SAX::SAXException("Top-level element must be 'stylesheet' or 'transform'.");
   
   static const ValueRule rules[] = { { "version", true, 0, 0 },
                                      { "extension-element-prefixes", false, 0, 0 },
                                      { "exclude-result-prefixes", false, 0, 0 },
                                      { "id", false, 0, 0 },
                                      { 0, false, 0, 0 } };
   std::map<std::string, std::string> attributes = gatherAttributes(qName, atts, rules);
   if(attributes["version"] != StylesheetConstant::Version())
     throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer.");
   if(!attributes["extension-element-prefixes"].empty())
     throw SAX::SAXException("Haven't implemented extension-element-prefixes yet");
 } // startStylesheet
Example #7
0
DataSourceMetaData::DataSourceMetaData(IHqlExpression * _record, byte _numFieldsToIgnore, bool _randomIsOk, bool _isGrouped, unsigned _keyedSize)
{
    init();
    numFieldsToIgnore = _numFieldsToIgnore;
    randomIsOk = _randomIsOk;
    isStoredFixedWidth = true;
    //MORE: Blobs aren't handled correctly in indexes....
    maxRecordSize = ::getMaxRecordSize(_record, MAX_RECORD_SIZE);
    keyedSize = _keyedSize;

    gatherFields(_record, false);
    if (_isGrouped)
    {
        Owned<ITypeInfo> type = makeBoolType();
        addSimpleField("__groupfollows__", NULL, type);
        maxRecordSize++;
    }
    gatherAttributes();

    if (isStoredFixedWidth)
        assertex(storedFixedSize == maxRecordSize);
}
  virtual VType* createContainer(const std::string& /* namespaceURI */,
                                 const std::string& /* localName */,
                                 const std::string& qName,
                                 const SAX::Attributes<std::string>& atts)
  {
    static const ValueRule rules[] = { { "name", true, 0, 0 },
                                       { "select", false, 0, 0 },
                                       { 0, false, 0, 0 } };

    
    std::map<std::string, std::string> attrs = gatherAttributes(qName, atts, rules);

    const std::string& select = atts.getValue("select");
    Arabica::XPath::XPathExpressionPtr<std::string> xpath;
    if(select != "")
    {
      xpath = this->context().xpath_expression(select);
      has_select_ = true;
    } // if ...

    std::string name = this->context().processInternalQName(attrs["name"]).clarkName();
    return new VType(name, xpath, precedence_);
  } // createContainer