You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ga...@apache.org on 2003/11/24 13:27:57 UTC

cvs commit: xml-xerces/c/src/xercesc/util XMLUni.hpp XMLUni.cpp

gareth      2003/11/24 04:27:57

  Modified:    c/src/xercesc/dom/impl DOMWriterImpl.cpp
               c/src/xercesc/util XMLUni.hpp XMLUni.cpp
  Log:
  added in support for xml-declaration feature.
  
  Revision  Changes    Path
  1.45      +24 -14    xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp
  
  Index: DOMWriterImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- DOMWriterImpl.cpp	24 Nov 2003 11:10:58 -0000	1.44
  +++ DOMWriterImpl.cpp	24 Nov 2003 12:27:57 -0000	1.45
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.45  2003/11/24 12:27:57  gareth
  + * added in support for xml-declaration feature.
  + *
    * Revision 1.44  2003/11/24 11:10:58  gareth
    * Fix for bug 22917. Patch by Adam Heinz .
    *
  @@ -232,6 +235,7 @@
   static const int VALIDATION_ID                    = 0x6;
   static const int WHITESPACE_IN_ELEMENT_CONTENT_ID = 0x7;
   static const int BYTE_ORDER_MARK_ID               = 0x8;
  +static const int XML_DECLARATIION                 = 0x9;
   
   //    feature                      true                       false
   // ================================================================================
  @@ -259,7 +263,8 @@
       true,  true,  // split-cdata-sections
       false, true,  // validation
       true,  false, // whitespace-in-element-content
  -    true,  true   // byte-order-mark
  +    true,  true,   // byte-order-mark
  +    true,  true   // xml-declaration
   };
   
   // default end-of-line sequence
  @@ -509,6 +514,8 @@
       setFeature(VALIDATION_ID,                    false);
       setFeature(WHITESPACE_IN_ELEMENT_CONTENT_ID, true );
       setFeature(BYTE_ORDER_MARK_ID,               false);
  +    setFeature(XML_DECLARATIION,                 true );
  +
   }
   
   bool DOMWriterImpl::canSetFeature(const XMLCh* const featName
  @@ -886,19 +893,19 @@
               //[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName
               //[32] SDDecl       ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
               //
  -            // We always print out the xmldecl no matter whether it is
  -            // present in the original XML instance document or not.
  -            //
  -            const XMLCh* versionNo = (docu->getVersion()) ? docu->getVersion() : gXMLDecl_ver10;
  -            *fFormatter << gXMLDecl_VersionInfo << versionNo << gXMLDecl_separator;
  -
  -            // use the encoding resolved in initSession()
  -            *fFormatter << gXMLDecl_EncodingDecl << fEncodingUsed << gXMLDecl_separator;
   
  -            const XMLCh* st = (docu->getStandalone())? XMLUni::fgYesString : XMLUni::fgNoString;
  -            *fFormatter << gXMLDecl_SDDecl << st << gXMLDecl_separator;
  -
  -            *fFormatter << gXMLDecl_endtag;
  +            if (getFeature(XML_DECLARATIION)) {
  +                const XMLCh* versionNo = (docu->getVersion()) ? docu->getVersion() : gXMLDecl_ver10;
  +                *fFormatter << gXMLDecl_VersionInfo << versionNo << gXMLDecl_separator;
  +
  +                // use the encoding resolved in initSession()
  +                *fFormatter << gXMLDecl_EncodingDecl << fEncodingUsed << gXMLDecl_separator;
  +
  +                const XMLCh* st = (docu->getStandalone())? XMLUni::fgYesString : XMLUni::fgNoString;
  +                *fFormatter << gXMLDecl_SDDecl << st << gXMLDecl_separator;
  +                
  +                *fFormatter << gXMLDecl_endtag;
  +            }
   
               DOMNodeSPtr child = nodeToWrite->getFirstChild();
               while( child != 0)
  @@ -1455,6 +1462,9 @@
           featureId = WHITESPACE_IN_ELEMENT_CONTENT_ID;
       else if (XMLString::equals(featName, XMLUni::fgDOMWRTBOM))
           featureId = BYTE_ORDER_MARK_ID;
  +    else if (XMLString::equals(featName, XMLUni::fgDOMXMLDeclaration))
  +        featureId = XML_DECLARATIION;
  +
   
       //feature name not resolvable
       if (featureId == INVALID_FEATURE_ID)
  
  
  
  1.31      +3 -1      xml-xerces/c/src/xercesc/util/XMLUni.hpp
  
  Index: XMLUni.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- XMLUni.hpp	22 Oct 2003 20:33:42 -0000	1.30
  +++ XMLUni.hpp	24 Nov 2003 12:27:57 -0000	1.31
  @@ -288,6 +288,8 @@
       static const XMLCh fgDOMWRTValidation[];
       static const XMLCh fgDOMWRTWhitespaceInElementContent[];
       static const XMLCh fgDOMWRTBOM[];
  +    static const XMLCh fgDOMXMLDeclaration[];
  +
   
       // Locale
       static const char  fgXercescDefaultLocale[];
  
  
  
  1.37      +9 -1      xml-xerces/c/src/xercesc/util/XMLUni.cpp
  
  Index: XMLUni.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- XMLUni.cpp	22 Oct 2003 20:33:42 -0000	1.36
  +++ XMLUni.cpp	24 Nov 2003 12:27:57 -0000	1.37
  @@ -1388,6 +1388,14 @@
       chLatin_m, chLatin_a, chLatin_r, chLatin_k, chNull
   };
   
  +//xml-declaration
  +const XMLCh XMLUni::fgDOMXMLDeclaration[] =
  +{ 
  +    chLatin_x, chLatin_m, chLatin_l, chDash, chLatin_d, chLatin_e, chLatin_c,
  +    chLatin_l, chLatin_a, chLatin_r, chLatin_a, chLatin_t, chLatin_i, chLatin_o,
  +    chLatin_n, chNull 
  +};
  +
   // en_US
   const char XMLUni::fgXercescDefaultLocale[] = "en_US";
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org