Пример #1
0
int XmlEnc_Model (OSCTXT* pctxt, Model* pvalue, const OSUTF8CHAR* elemName, 
   const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, FALSE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   /* add attributes */
   { OSRTDListNode* pnode = pvalue->attr.head;
   size_t len;
   while (0 != pnode) {
      len = rtxUTF8LenBytes (pnode->data);

      stat = rtxCheckBuffer (pctxt, len + 1);
      if (stat != 0) return LOG_RTERR (pctxt, stat);

      OSRTPUTCHAR (pctxt, ' ');
      OSRTMEMCPY (pctxt, pnode->data, len);

      pnode = pnode->next;
   }}

   OSRTSAFEPUTCHAR (pctxt, '>');
   pctxt->flags &= ~OSTERMSTART;
   pctxt->state = OSXMLSTART;

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.w3.org/2002/xforms"));

   /* encode element14_list */

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.w3.org/2002/xforms"));

   { OSRTDListNode* pnode = pvalue->element14_list.head;
   while (0 != pnode) {
      stat = XmlEnc_Odf_Element14 (pctxt, *((Odf_Element14*)pnode->data)
         , 0, nsPrefix);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
      pnode = pnode->next;
   }}
   nsPrefix = savedPrefix;
   }

   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #2
0
int XmlEnc_InvoiceType (OSCTXT* pctxt, InvoiceType* pvalue, 
   const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   /* encode header */

   stat = XmlEnc_InvoiceHeaderType (pctxt, &pvalue->header
      , OSUTF8("Header"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode lineItem_list */

   if (!(pvalue->lineItem_list.count >= 1U)) {
      rtxErrAddStrParm (pctxt, "InvoiceType.lineItem_list.count");
      rtxErrAddIntParm (pctxt, (int)pvalue->lineItem_list.count);
      return LOG_RTERR (pctxt, RTERR_CONSVIO);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   { OSRTDListNode* pnode = pvalue->lineItem_list.head;
   while (0 != pnode) {
      stat = XmlEnc_InvoiceLineItemType (pctxt, 
         ((InvoiceLineItemType*)pnode->data), OSUTF8("LineItem"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
      pnode = pnode->next;
   }}
   nsPrefix = savedPrefix;
   }

   /* encode summary */

   stat = XmlEnc_InvoiceSummaryType (pctxt, &pvalue->summary
      , OSUTF8("Summary"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #3
0
int XmlEnc_EncodingStyle_1 (OSCTXT* pctxt, EncodingStyle_1* pvalue, 
   const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (elemName != 0) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://schemas.xmlsoap.org/soap/envelope/"));

   { OSRTDListNode* pnode = pvalue->head;
   while (0 != pnode) {
      stat = rtXmlEncUTF8Str (pctxt, ((const OSUTF8CHAR*)pnode->data)
         , OSUTF8(""), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
      OSRTSAFEPUTCHAR (pctxt, ' ');
      pnode = pnode->next;
   }}
   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #4
0
int XmlEnc_Fault_PDU (OSCTXT* pctxt, Fault* pvalue)
{
   int stat;
   const OSUTF8CHAR* nsPrefix = 0;

   rtXmlNSSetNamespace (pctxt, OSUTF8("tns"), 
      OSUTF8("http://schemas.xmlsoap.org/soap/envelope/"), FALSE);

   nsPrefix = rtXmlNSGetPrefix (pctxt, 
      OSUTF8("http://schemas.xmlsoap.org/soap/envelope/"));

   stat = rtXmlEncStartDocument (pctxt);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncStartElement (pctxt, OSUTF8("Fault"), nsPrefix, FALSE);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncNSAttrs (pctxt);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncXSIAttrs (pctxt, FALSE);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = XmlEnc_Fault (pctxt, pvalue, 0, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncEndElement (pctxt, OSUTF8("Fault"), nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return stat;
}
Пример #5
0
int XmlEnc_Fault (OSCTXT* pctxt, Fault* pvalue, const OSUTF8CHAR* elemName, 
   const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://schemas.xmlsoap.org/soap/envelope/"));

   /* encode faultcode */

   stat = rtXmlEncUTF8Str (pctxt, pvalue->faultcode.
      name, OSUTF8("faultcode"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode faultstring */

   stat = rtXmlEncUTF8Str (pctxt, pvalue->faultstring
      , OSUTF8("faultstring"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode faultactor */

   if (pvalue->m.faultactorPresent) {
      stat = rtXmlEncUTF8Str (pctxt, pvalue->faultactor
         , OSUTF8("faultactor"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode detail */

   if (pvalue->m.detailPresent) {
      stat = XmlEnc_Detail (pctxt, &pvalue->detail, OSUTF8("detail"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #6
0
int XmlEnc_Ns1_Min_width (OSCTXT* pctxt, Ns1_Min_width* pvalue, 
   const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"));

   switch (pvalue->t)
   {
      case 1:
         /* encode alt */

         stat = rtXmlEncUTF8Str (pctxt, pvalue->u.alt, 0, 0);
         if (stat != 0) return LOG_RTERR (pctxt, stat);

         break;

      case 2:
         /* encode alt_1 */

         stat = rtXmlEncUTF8Str (pctxt, pvalue->u.alt_1, 0, 0);
         if (stat != 0) return LOG_RTERR (pctxt, stat);

         break;

      default: {
         char buf[40];
         os_snprintf (buf, 40, "%d", pvalue->t);
         return LOG_RTERRNEW1 (pctxt, RTERR_INVOPT, 
            rtxErrAddStrParm (pctxt, buf));
      }
   }
   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #7
0
int XmlEnc_Invoice_PDU (OSCTXT* pctxt, Invoice* pvalue)
{
   int stat;
   const OSUTF8CHAR* nsPrefix = 0;

   rtXmlNSSetNamespace (pctxt, OSUTF8("cct"), 
      OSUTF8("urn:oasis:names:tc:ubl:CommonLeafTypes:1.0:0.65"), FALSE);

   rtXmlNSSetNamespace (pctxt, OSUTF8("cmn"), 
      OSUTF8("http://www.sun.com/schema/spidermarkexpress/sm-common"), FALSE);

   rtXmlNSSetNamespace (pctxt, OSUTF8("jxb"), 
      OSUTF8("http://java.sun.com/xml/ns/jaxb"), FALSE);

   rtXmlNSSetNamespace (pctxt, 0, 
      OSUTF8("http://www.sun.com/schema/spidermarkexpress/sm-inv"), FALSE);

   nsPrefix = rtXmlNSGetPrefix (pctxt, 
      OSUTF8("http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   stat = rtXmlEncStartDocument (pctxt);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncStartElement (pctxt, OSUTF8("invoice"), nsPrefix, FALSE);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncNSAttrs (pctxt);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncXSIAttrs (pctxt, FALSE);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = XmlEnc_Invoice (pctxt, pvalue, 0, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   stat = rtXmlEncEndElement (pctxt, OSUTF8("invoice"), nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return stat;
}
Пример #8
0
int XmlEnc_Detail (OSCTXT* pctxt, Detail* pvalue, const OSUTF8CHAR* elemName, 
   const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, FALSE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   /* add attributes */
   { OSRTDListNode* pnode = pvalue->attr.head;
   size_t len;
   while (0 != pnode) {
      len = rtxUTF8LenBytes (pnode->data);

      stat = rtxCheckBuffer (pctxt, len + 1);
      if (stat != 0) return LOG_RTERR (pctxt, stat);

      OSRTPUTCHAR (pctxt, ' ');
      OSRTMEMCPY (pctxt, pnode->data, len);

      pnode = pnode->next;
   }}

   OSRTSAFEPUTCHAR (pctxt, '>');
   pctxt->flags &= ~OSTERMSTART;
   pctxt->state = OSXMLSTART;

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://schemas.xmlsoap.org/soap/envelope/"));

   /* encode elem_list */

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://schemas.xmlsoap.org/soap/envelope/"));

   { OSRTDListNode* pnode = pvalue->elem_list.head;
   while (0 != pnode) {
      if (((OSXSDAny*)pnode->data)->t == OSXSDAny_xmlText) {
         stat = rtXmlEncAnyStr (pctxt, ((OSXSDAny*)pnode->data)->u.xmlText
            , OSUTF8(""), 0);
         if (stat != 0) return LOG_RTERR (pctxt, stat);
      }
      else {
         char buf[40];
         os_snprintf (buf, 40, "%d", ((OSXSDAny*)pnode->data)->t);
         rtxErrAddStrParm (pctxt, buf);
         return LOG_RTERR (pctxt, RTERR_INVOPT);
      }
      pnode = pnode->next;
   }}
   nsPrefix = savedPrefix;
   }

   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #9
0
int XmlEnc_InvoiceSummaryType (OSCTXT* pctxt, InvoiceSummaryType* pvalue, 
   const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   /* encode lineItemCountValue */

   if (pvalue->m.lineItemCountValuePresent) {
      stat = XmlEnc_CCT_NumericType (pctxt, &pvalue->lineItemCountValue
         , OSUTF8("LineItemCountValue"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode subtotalAmount */

   stat = XmlEnc_CCT_AmountType (pctxt, &pvalue->subtotalAmount
      , OSUTF8("SubtotalAmount"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode pricingVariation_list */

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   { OSRTDListNode* pnode = pvalue->pricingVariation_list.head;
   while (0 != pnode) {
      stat = XmlEnc_PricingVariationType (pctxt, 
         ((PricingVariationType*)pnode->data), OSUTF8("PricingVariation"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
      pnode = pnode->next;
   }}
   nsPrefix = savedPrefix;
   }

   /* encode totalTax */

   if (pvalue->m.totalTaxPresent) {
      stat = XmlEnc_TaxType (pctxt, &pvalue->totalTax, OSUTF8("TotalTax"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode priceAmount */

   stat = XmlEnc_CCT_AmountType (pctxt, &pvalue->priceAmount
      , OSUTF8("PriceAmount"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode packingSlipIdentifier */

   if (pvalue->m.packingSlipIdentifierPresent) {
      stat = XmlEnc_CCT_IdentifierType (pctxt, &pvalue->packingSlipIdentifier
         , OSUTF8("PackingSlipIdentifier"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode summaryNote */

   if (pvalue->m.summaryNotePresent) {
      stat = XmlEnc_NoteType (pctxt, &pvalue->summaryNote
         , OSUTF8("SummaryNote"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #10
0
int XmlEnc_InvoiceLineItemType (OSCTXT* pctxt, InvoiceLineItemType* pvalue, 
   const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   /* encode lineID */

   stat = XmlEnc_CCT_IdentifierType (pctxt, &pvalue->lineID
      , OSUTF8("LineID"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode item */

   stat = XmlEnc_ItemType (pctxt, &pvalue->item, OSUTF8("Item"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode orderStatus */

   if (pvalue->m.orderStatusPresent) {
      stat = XmlEnc_CCT_CodeType (pctxt, &pvalue->orderStatus
         , OSUTF8("OrderStatus"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode pricing */

   stat = XmlEnc_PricingType (pctxt, &pvalue->pricing, OSUTF8("Pricing"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode pricingVariation */

   if (pvalue->m.pricingVariationPresent) {
      stat = XmlEnc_PricingVariationType (pctxt, &pvalue->pricingVariation
         , OSUTF8("PricingVariation"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode itemTax */

   if (pvalue->m.itemTaxPresent) {
      stat = XmlEnc_CCT_AmountType (pctxt, &pvalue->itemTax
         , OSUTF8("ItemTax"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode totalAmount */

   stat = XmlEnc_CCT_AmountType (pctxt, &pvalue->totalAmount
      , OSUTF8("TotalAmount"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #11
0
int XmlEnc_InvoiceHeaderType (OSCTXT* pctxt, InvoiceHeaderType* pvalue, 
   const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix)
{
   int stat = 0;

   if (0 != elemName) {
      stat = rtXmlEncStartElement (pctxt, elemName, nsPrefix, TRUE);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }

   { const OSUTF8CHAR* savedPrefix = nsPrefix;
   nsPrefix = rtXmlNSGetPrefix (pctxt, OSUTF8(
      "http://www.sun.com/schema/spidermarkexpress/sm-inv"));

   /* encode issueDateTime */

   stat = XmlEnc_CCT_DateTimeType (pctxt, &pvalue->issueDateTime
      , OSUTF8("IssueDateTime"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode identifier */

   stat = XmlEnc_CCT_IdentifierType (pctxt, &pvalue->identifier
      , OSUTF8("Identifier"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode pOIdentifier */

   stat = XmlEnc_CCT_IdentifierType (pctxt, &pvalue->pOIdentifier
      , OSUTF8("POIdentifier"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode currencyCode */

   if (pvalue->m.currencyCodePresent) {
      stat = XmlEnc_CCT_CodeType (pctxt, &pvalue->currencyCode
         , OSUTF8("CurrencyCode"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode language */

   if (pvalue->m.languagePresent) {
      stat = XmlEnc_LanguageType (pctxt, &pvalue->language
         , OSUTF8("Language"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode buyerParty */

   stat = XmlEnc_PartyType (pctxt, &pvalue->buyerParty
      , OSUTF8("BuyerParty"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode sellerParty */

   stat = XmlEnc_PartyType (pctxt, &pvalue->sellerParty
      , OSUTF8("SellerParty"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode consigneeParty */

   if (pvalue->m.consigneePartyPresent) {
      stat = XmlEnc_PartyType (pctxt, &pvalue->consigneeParty
         , OSUTF8("ConsigneeParty"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode despatchParty */

   if (pvalue->m.despatchPartyPresent) {
      stat = XmlEnc_PartyType (pctxt, &pvalue->despatchParty
         , OSUTF8("DespatchParty"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode shipment */

   if (pvalue->m.shipmentPresent) {
      stat = XmlEnc_ShipmentType (pctxt, &pvalue->shipment
         , OSUTF8("Shipment"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   /* encode paymentMeans */

   stat = XmlEnc_PaymentMeansType (pctxt, &pvalue->paymentMeans
      , OSUTF8("PaymentMeans"), 0);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   /* encode lineItemCountValue */

   if (pvalue->m.lineItemCountValuePresent) {
      stat = XmlEnc_CCT_NumericType (pctxt, &pvalue->lineItemCountValue
         , OSUTF8("LineItemCountValue"), 0);
      if (stat != 0) return LOG_RTERR (pctxt, stat);
   }
   nsPrefix = savedPrefix;
   }

   stat = rtXmlEncEndElement (pctxt, elemName, nsPrefix);
   if (stat != 0) return LOG_RTERR (pctxt, stat);

   return (stat);
}
Пример #12
0
EXTXMLMETHOD int rtXmlEncStartElement (OSCTXT* pctxt,
                                       const OSUTF8CHAR* elemName,
                                       OSXMLNamespace* pNS,
                                       OSRTDList* pNSAttrs,
                                       OSBOOL terminate)
{
    int stat = 0;

    if (0 != elemName && 0 != *elemName) {
        size_t elemLen = rtxUTF8LenBytes (elemName);
        size_t nsPrefixLen;
        size_t specChars;

        /* Push null entry onto namespace stack */
        stat = rtXmlNSPush (pctxt);
        if (stat != 0) return LOG_RTERR (pctxt, stat);

        /* Set namespace URI/prefix links */
        stat = rtXmlSetNSPrefixLinks (pctxt, pNSAttrs);
        if (stat != 0) return LOG_RTERR (pctxt, stat);

        /* Set namespace prefix in passed namespace structure */
        if (0 != pNS) {
            if (0 == pNS->prefix) {
                pNS->prefix = rtXmlNSGetPrefix (pctxt, pNS->uri);
            }
            nsPrefixLen = OSUTF8LEN (pNS->prefix);
        }
        else nsPrefixLen = 0;

        specChars = (0 != nsPrefixLen) ? 3 : 2;

        /* Terminate previous element if still open */
        stat = rtXmlEncTermStartElement (pctxt);
        if (stat != 0) return LOG_RTERR (pctxt, stat);

        stat = rtXmlEncIndent (pctxt);
        if (stat != 0) return LOG_RTERR (pctxt, stat);

        pctxt->level++;
        pctxt->state = OSXMLSTART;

        /* Verify element will fit in encode buffer */

        stat = rtxCheckBuffer (pctxt, elemLen + nsPrefixLen + specChars);
        if (stat != 0) return LOG_RTERR (pctxt, stat);

        /* Copy data to buffer */

        OSRTPUTCHAR (pctxt, '<');

        if (0 != nsPrefixLen) {
            OSRTMEMCPY (pctxt, pNS->prefix, nsPrefixLen);
            OSRTPUTCHAR (pctxt, ':');
        }
        OSRTMEMCPY (pctxt, elemName, elemLen);

        if (terminate) {
            OSRTPUTCHAR (pctxt, '>');
            pctxt->flags &= ~OSTERMSTART;
        }
        else /* set flag in context indicating terminator needed */
            pctxt->flags |= OSTERMSTART;

#ifndef _COMPACT
        /* Add name to element name stack in context */
        rtxDListAppend (pctxt, &pctxt->elemNameStack, (void*)elemName);
#endif
        if (!terminate && rtxCtxtTestFlag (pctxt, OSXMLC14N))
            stat = rtXmlEncStartAttrC14N (pctxt);
    }
    else if (terminate) {
        stat = rtXmlEncTermStartElement (pctxt);
    }

    if (stat < 0) return LOG_RTERR (pctxt, stat);
    return 0;
}