~ubuntu-branches/ubuntu/natty/libxml++2.6/natty

« back to all changes in this revision

Viewing changes to libxml++/validators/dtdvalidator.cc

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-09-18 11:32:24 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20070918113224-7x031mzf1shoozxx
Tags: 2.20.0-0ubuntu1
* New upstream release:
  - Element: Added get_attribute_value(), to get a simple text value for an
    attribute.
  - Added an experimental --enable-api-exceptions configure option, to allow
    libxml++ to build without exceptions.
* debian/libxml++2.6-doc.docs: 2.18 -> 2.20.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    external.empty() ? 0 : (const xmlChar *)external.c_str(),
59
59
    system.empty() ? 0 : (const xmlChar *)system.c_str());
60
60
 
61
 
  if ( ! dtd )
62
 
     throw parse_error("Dtd could not be parsed");
 
61
  if (!dtd)
 
62
  {
 
63
    #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
 
64
    throw parse_error("Dtd could not be parsed");
 
65
    #else
 
66
    return;
 
67
    #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
 
68
  }
63
69
 
64
70
  dtd_ = static_cast<Dtd*>(dtd->_private);
65
71
}
80
86
 
81
87
  xmlDtd* dtd = xmlIOParseDTD( 0, ibuff.cobj(), XML_CHAR_ENCODING_UTF8 );
82
88
 
83
 
  if ( ! dtd )
84
 
     throw parse_error("Dtd could not be parsed");
 
89
  if (!dtd)
 
90
  {
 
91
    #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
 
92
    throw parse_error("Dtd could not be parsed");
 
93
    #else
 
94
    return;
 
95
    #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
 
96
  }
85
97
 
86
98
  dtd_ = static_cast<Dtd*>(dtd->_private);
87
99
}
118
130
 
119
131
  if(!valid_)
120
132
  {
 
133
    #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
121
134
    throw internal_error("Couldn't create parsing context");
 
135
    #else
 
136
    return false;
 
137
    #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
122
138
  }
123
139
 
124
140
  if (!doc)
 
141
  {
 
142
    #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
125
143
    throw internal_error("Document pointer cannot be 0");
 
144
    #else
 
145
    return false;
 
146
    #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
 
147
  }
126
148
 
127
149
  initialize_valid();
128
150
 
129
 
  bool res = (bool)xmlValidateDtd( valid_, (xmlDoc*)doc->cobj(), dtd_->cobj() );
 
151
  const bool res = (bool)xmlValidateDtd( valid_, (xmlDoc*)doc->cobj(), dtd_->cobj() );
130
152
 
131
153
  if(res == 0)
132
154
  {
133
155
    check_for_exception();
 
156
 
 
157
    #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
134
158
    throw validity_error("Document failed Dtd validation");
 
159
    #else
 
160
    return false;
 
161
    #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
135
162
  }
136
163
 
137
164
  return res;