aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/parser/parser-inline.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-11 12:43:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-11 12:43:48 +0200
commit9553149aa6b6561c49981adf2848607a43765054 (patch)
treeff941ad89aa2c87ec5ddbd7a7bdd189fc33f87ba /xsde/cxx/parser/parser-inline.cxx
parent0dd6d623af5dfe3590d0c269f76a2fa322e75e58 (diff)
Support for validation of the pattern facet
New test: hybrid/pattern.
Diffstat (limited to 'xsde/cxx/parser/parser-inline.cxx')
-rw-r--r--xsde/cxx/parser/parser-inline.cxx107
1 files changed, 68 insertions, 39 deletions
diff --git a/xsde/cxx/parser/parser-inline.cxx b/xsde/cxx/parser/parser-inline.cxx
index 984eca6..d20a3e7 100644
--- a/xsde/cxx/parser/parser-inline.cxx
+++ b/xsde/cxx/parser/parser-inline.cxx
@@ -17,54 +17,83 @@ namespace CXX
Void
facet_calls (SemanticGraph::Complex& c, Context& ctx)
{
+ using SemanticGraph::Restricts;
+
std::wostream& os (ctx.os);
- using SemanticGraph::Restricts;
+ SemanticGraph::Type& ub (ctx.ultimate_base (c));
Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
- for (Restricts::FacetIterator i (r.facet_begin ());
- i != r.facet_end (); ++i)
+ if (ub.is_a<SemanticGraph::Fundamental::String> () ||
+ ub.is_a<SemanticGraph::Fundamental::AnyURI> ())
{
- if (i->first == L"length")
- {
- os << "this->_length_facet (" << i->second << "UL);";
- }
- else if (i->first == L"minLength")
- {
- os << "this->_min_length_facet (" << i->second << "UL);";
- }
- else if (i->first == L"maxLength")
- {
- os << "this->_max_length_facet (" << i->second << "UL);";
- }
- else if (i->first == L"minInclusive")
- {
- os << "this->_min_facet (" << i->second << ", true);";
- }
- else if (i->first == L"minExclusive")
+ for (Restricts::FacetIterator i (r.facet_begin ());
+ i != r.facet_end (); ++i)
{
- os << "this->_min_facet (" << i->second << ", false);";
- }
- else if (i->first == L"maxInclusive")
- {
- os << "this->_max_facet (" << i->second << ", true);";
- }
- else if (i->first == L"maxExclusive")
- {
- os << "this->_max_facet (" << i->second << ", false);";
+ if (i->first == L"whiteSpace")
+ {
+ os << "this->_whitespace_facet (";
+
+ if (i->second == L"preserve")
+ os << "0";
+ else if (i->second == L"replace")
+ os << "1";
+ else if (i->second == L"collapse")
+ os << "2";
+
+ os << ");";
+ continue;
+ }
+
+ if (!ctx.validation)
+ continue;
+
+ if (i->first == L"length")
+ {
+ os << "this->_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"minLength")
+ {
+ os << "this->_min_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"maxLength")
+ {
+ os << "this->_max_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"pattern")
+ {
+ os << "this->_pattern_facet (" << ctx.strlit (i->second) << ");";
+ }
}
- else if (i->first == L"whiteSpace")
- {
- os << "this->_whitespace_facet (";
+ }
- if (i->second == L"preserve")
- os << "0";
- else if (i->second == L"replace")
- os << "1";
- else if (i->second == L"collapse")
- os << "2";
+ if (ub.is_a<SemanticGraph::Fundamental::Short> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedByte> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedShort> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedInt> ())
+ {
+ for (Restricts::FacetIterator i (r.facet_begin ());
+ i != r.facet_end (); ++i)
+ {
+ if (!ctx.validation)
+ continue;
- os << ");";
+ if (i->first == L"minInclusive")
+ {
+ os << "this->_min_facet (" << i->second << ", true);";
+ }
+ else if (i->first == L"minExclusive")
+ {
+ os << "this->_min_facet (" << i->second << ", false);";
+ }
+ else if (i->first == L"maxInclusive")
+ {
+ os << "this->_max_facet (" << i->second << ", true);";
+ }
+ else if (i->first == L"maxExclusive")
+ {
+ os << "this->_max_facet (" << i->second << ", false);";
+ }
}
}
}