Commit af5c331d authored by Louis-Nol Pouchet's avatar Louis-Nol Pouchet
Browse files

2005-05-15 Louis-Noel Pouchet <louis-noel.pouchet@lrde.epita.fr>

	* include/vaucanson/xml/xml_chooser.hh,
	* include/vaucanson/xml/node.hh,
	* include/vaucanson/xml/xml_converter.hh,
	* include/vaucanson/xml/tools.hh,
	* include/vaucanson/xml/xerces_parser.hh: Fix some include problems.
	
	* include/vaucanson/xml/XML.hh: Move macro definitions ...
	* include/vaucanson/tools/usual_macros.hh:... here.
	
	* include/vaucanson/xml/if_tag.hh,
	* include/vaucanson/xml/if_tag.hxx: Delete. These files are inaccurate
	at the moment. They will be fixed and re-added, if necessary.

	* include/vaucanson/xml/strings.hh: Remove a bad include.

	* doc/xml/vaucanson.xsd: Fix monoid and semiring order for 
	transducers. 
		
	* include/Makefile.am: Fix and update.
parent efbb9eb4
2005-05-15 Louis-Noel Pouchet <louis-noel.pouchet@lrde.epita.fr>
* include/vaucanson/xml/xml_chooser.hh,
* include/vaucanson/xml/node.hh,
* include/vaucanson/xml/xml_converter.hh,
* include/vaucanson/xml/tools.hh,
* include/vaucanson/xml/xerces_parser.hh: Fix some include problems.
* include/vaucanson/xml/XML.hh: Move macro definitions ...
* include/vaucanson/tools/usual_macros.hh:... here.
* include/vaucanson/xml/if_tag.hh,
* include/vaucanson/xml/if_tag.hxx: Delete. These files are inaccurate
at the moment. They will be fixed and re-added, if necessary.
* include/vaucanson/xml/strings.hh: Remove a bad include.
* doc/xml/vaucanson.xsd: Fix monoid and semiring order for
transducers.
* include/Makefile.am: Fix and update.
2005-05-15 Louis-Noel Pouchet <louis-noel.pouchet@lrde.epita.fr>
* src/tests/xml/import_dynamic-simple.xml.ref,
......
......@@ -75,8 +75,8 @@ The default semiring is Boolean.
-->
<xs:complexType name="semiring">
<xs:sequence>
<xs:element name="semiring" type="semiring" minOccurs="0"/>
<xs:element name="monoid" type="monoid_automaton" minOccurs="0"/>
<xs:element name="semiring" type="semiring" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="set" default="B">
<xs:simpleType>
......
......@@ -360,12 +360,9 @@ nobase_include_HEADERS = \
XMLSOURCES = \
vaucanson/xml/error_handler.hh \
vaucanson/xml/error_handler.hxx \
vaucanson/xml/errors.hh \
vaucanson/xml/infos.hh \
vaucanson/xml/ios.hh \
vaucanson/xml/ios.hxx \
vaucanson/xml/if_tag.hh \
vaucanson/xml/if_tag.hxx \
vaucanson/xml/strings.hh \
vaucanson/xml/strings.hxx \
vaucanson/xml/XML.hh \
......
......@@ -190,6 +190,18 @@ typedef typename alphabet_t::letter_t letter_t;
#define RAND___(Max) \
((unsigned) int(((float) rand() / (float) RAND_MAX) * Max));
// Some useful macros for XML.
#ifndef VCSN_NDEBUG
# define XML_FAIL(S) \
std::cerr << "Implement for " << typeid(S).name() << std::endl; \
exit(1)
#else
# define XML_FAIL(S)
#endif
#define FAIL(S) { std::cerr << (S) << std::endl; exit(1); }
#define STR2XML(S) xercesc::XMLString::transcode(S)
//
// These macros can be use instead of some method calls.
// This is really tricky and dirty but so useful !
......
......@@ -44,18 +44,7 @@
*/
// Some useful macros.
# ifndef VCSN_NDEBUG
# define XML_FAIL(S) \
std::cerr << "Implement for " << typeid(S).name() << std::endl; \
exit(1)
# else
# define XML_FAIL(S)
# endif
# define FAIL(S) { std::cerr << (S) << std::endl; exit(1); }
# define STR2XML(S) xercesc::XMLString::transcode(S)
# include <vaucanson/tools/usual_macros.hh>
# include <vaucanson/xml/xml_converter.hh>
......
// if_tag.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
// Copyright (C) 2004 The Vaucanson Group.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// The Vaucanson Group consists of the following contributors:
// * Jacques Sakarovitch <sakarovitch@enst.fr>
// * Sylvain Lombardy <lombardy@liafa.jussieu.fr>
// * Thomas Claveirole <thomas.claveirole@lrde.epita.fr>
// * Loic Fosse <loic.fosse@lrde.epita.fr>
// * Thanh-Hoc Nguyen <nguyen@enst.fr>
// * Raphael Poss <raphael.poss@lrde.epita.fr>
// * Yann Regis-Gianas <yann.regis-gianas@lrde.epita.fr>
// * Maxime Rey <maxime.rey@lrde.epita.fr>
// * Sarah O'Connor <sarah.o-connor@lrde.epita.fr>
// * Louis-Noel Pouchet <louis-noel.pouchet@lrde.epita.fr>
//
#ifndef VCSN_XML_IF_TAG_HH
# define VCSN_XML_IF_TAG_HH
# include <xercesc/dom/DOM.hpp>
# include <vaucanson/automata/concept/handlers.hh>
# include <vaucanson/xml/types.hh>
# include <vaucanson/xml/infos.hh>
// FIXME: This file lacks documentation.
namespace vcsn
{
namespace xml
{
using xercesc::DOMElement;
using xercesc::DOMNode;
/*---------------.
| Generic if_tag |
`---------------*/
# define XML_IF_TAG_DECLARE_SET(Name, Args...) \
static \
void \
set_ ## Name (DOMElement*, Args) \
{ \
}
# define XML_IF_TAG_DECLARE_GET(Name, Args...) \
static \
void \
get_ ## Name(const DOMElement*, Args) \
{ \
}
template <typename Tag>
struct if_tag
{
XML_IF_TAG_DECLARE_SET(root, Tag)
XML_IF_TAG_DECLARE_SET(structure, Tag)
XML_IF_TAG_DECLARE_SET(states, Tag)
XML_IF_TAG_DECLARE_SET(edges, Tag)
XML_IF_TAG_DECLARE_SET(initials, Tag)
XML_IF_TAG_DECLARE_SET(finals, Tag)
XML_IF_TAG_DECLARE_SET(state, hstate_t, Tag)
XML_IF_TAG_DECLARE_SET(edge, hedge_t, Tag)
XML_IF_TAG_DECLARE_SET(initial, hstate_t, Tag)
XML_IF_TAG_DECLARE_SET(final, hstate_t, Tag)
XML_IF_TAG_DECLARE_GET(root, Tag&)
XML_IF_TAG_DECLARE_GET(structure, Tag&)
XML_IF_TAG_DECLARE_GET(states, Tag&)
XML_IF_TAG_DECLARE_GET(edges, Tag&)
XML_IF_TAG_DECLARE_GET(initials, Tag&)
XML_IF_TAG_DECLARE_GET(finals, Tag&)
XML_IF_TAG_DECLARE_GET(state, hstate_t, Tag&)
XML_IF_TAG_DECLARE_GET(edge, hedge_t, Tag&)
XML_IF_TAG_DECLARE_GET(initial, hstate_t, Tag&)
XML_IF_TAG_DECLARE_GET(final, hstate_t, Tag&)
static
DOMElement*
add_state(xml_automaton_impl_t& x, hstate_t s, const Tag&);
}; // End of class template if_tag<Tag>.
# undef XML_IF_TAG_DECLARE_GET
# undef XML_IF_TAG_DECLARE_SET
/*-------------------------------.
| Special if_tag for XmlInfosTag |
`-------------------------------*/
# define XML_IF_TAG_DECLARE_SET1(Name) \
static \
void \
set_ ## Name (DOMElement* node, XmlInfosTag tag) \
{ \
set_default(node, tag.get_ ## Name ()); \
}
# define XML_IF_TAG_DECLARE_SET2(Name, Arg2) \
static \
void \
set_ ## Name (DOMElement* node, Arg2 s, XmlInfosTag tag) \
{ \
set_default(node, tag.get_ ## Name ## s()[s]); \
}
# define XML_IF_TAG_DECLARE_GET1(Name) \
static \
void \
get_ ## Name (const DOMElement* node, XmlInfosTag& tag) \
{ \
get_default(node, tag.get_ ## Name ()); \
}
# define XML_IF_TAG_DECLARE_GET2(Name, Arg2) \
static \
void \
get_ ## Name (DOMElement* node, Arg2 s, XmlInfosTag& tag) \
{ \
get_default(node, tag.get_ ## Name ## s()[s]); \
}
template <>
struct if_tag<XmlInfosTag>
{
XML_IF_TAG_DECLARE_SET1(root)
XML_IF_TAG_DECLARE_SET1(structure)
XML_IF_TAG_DECLARE_SET1(states)
XML_IF_TAG_DECLARE_SET1(edges)
XML_IF_TAG_DECLARE_SET1(initials)
XML_IF_TAG_DECLARE_SET1(finals)
static
void
set_default(DOMElement* n, const XmlInfosTag::Geometry& g);
static
void
set_state(DOMElement* n, hstate_t s, XmlInfosTag tag);
XML_IF_TAG_DECLARE_SET2(edge, hedge_t)
XML_IF_TAG_DECLARE_SET2(initial, hstate_t)
XML_IF_TAG_DECLARE_SET2(final, hstate_t)
static
DOMElement*
add_state(xml_automaton_impl_t& x, hstate_t s, const XmlInfosTag& tag);
static
void
get_default(const DOMElement* n, XmlInfosTag::Geometry& g);
XML_IF_TAG_DECLARE_GET1(root)
XML_IF_TAG_DECLARE_GET1(structure)
XML_IF_TAG_DECLARE_GET1(states)
XML_IF_TAG_DECLARE_GET1(edges)
XML_IF_TAG_DECLARE_GET1(initials)
XML_IF_TAG_DECLARE_GET1(finals)
static
void
get_state(const DOMElement* n, hstate_t s, XmlInfosTag& tag);
XML_IF_TAG_DECLARE_GET2(edge, hedge_t)
XML_IF_TAG_DECLARE_GET2(initial, hstate_t)
XML_IF_TAG_DECLARE_GET2(final, hstate_t)
}; // End of specialized class if_tag<XmlInfosTag>.
# undef XML_IF_TAG_DECLARE_SET1
# undef XML_IF_TAG_DECLARE_SET2
# undef XML_IF_TAG_DECLARE_GET1
# undef XML_IF_TAG_DECLARE_GET2
} // End of namespace xml.
} // End of namespace vcsn.
# ifndef VCSN_USE_INTERFACE_ONLY
# include <vaucanson/xml/if_tag.hxx>
# endif // ! VCSN_USE_INTERFACE_ONLY
#endif // ! VCSN_XML_IF_TAG_HH
// if_tag.hxx: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
// Copyright (C) 2004 The Vaucanson Group.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// The Vaucanson Group consists of the following contributors:
// * Jacques Sakarovitch <sakarovitch@enst.fr>
// * Sylvain Lombardy <lombardy@liafa.jussieu.fr>
// * Thomas Claveirole <thomas.claveirole@lrde.epita.fr>
// * Loic Fosse <loic.fosse@lrde.epita.fr>
// * Thanh-Hoc Nguyen <nguyen@enst.fr>
// * Raphael Poss <raphael.poss@lrde.epita.fr>
// * Yann Regis-Gianas <yann.regis-gianas@lrde.epita.fr>
// * Maxime Rey <maxime.rey@lrde.epita.fr>
// * Sarah O'Connor <sarah.o-connor@lrde.epita.fr>
// * Louis-Noel Pouchet <louis-noel.pouchet@lrde.epita.fr>
//
#ifndef VCSN_XML_IF_TAG_HXX
# define VCSN_XML_IF_TAG_HXX
# include <sstream>
# include <vaucanson/xml/if_tag.hh>
# include <vaucanson/xml/strings.hh>
# include <vaucanson/xml/xml_automaton.hh>
namespace vcsn
{
namespace xml
{
/*---------------.
| Generic if_tag |
`---------------*/
template <class Tag>
DOMElement*
if_tag<Tag>::add_state(xml_automaton_impl_t& x, hstate_t s, const Tag&)
{
x.add_state(s);
return 0;
}
/*-------------------------------.
| Special if_tag for XmlInfosTag |
`-------------------------------*/
# define SET_ATTR(Section, Attr) \
if ( Section (). get_##Attr ().is_set()) \
{ \
std::ostringstream strs; \
strs << (Section (). get_##Attr() ()); \
node->removeAttribute(str_##Attr); \
XMLCh* value = XMLString::transcode(strs.str().c_str()); \
if (node->hasAttribute(str_##Attr)) \
{ \
if (XMLString::compareIString(node-> \
getAttribute(str_##Attr), \
value)) \
node->setAttribute(str_##Attr, value); \
} \
else \
node->setAttribute(str_##Attr, value); \
XMLString::release(&value); \
}
# define OPTION_ATTR(Field, Attr, Do) \
if ( Field() . get_##Attr() .is_set()) \
{ \
Do \
}
# define OPTION(Section, Attr, Value, Str) \
if ( Section (). get_##Attr ()() == Value ) \
node->setAttribute(str_##Attr, str_##Str);
inline
void
if_tag<XmlInfosTag>::set_default(DOMElement* n,
const XmlInfosTag::Geometry& g)
{
DOMElement* node = 0;
DOMNode* child = n->getFirstChild();
while (child)
{
if (child->getNodeType() == DOMNode::ELEMENT_NODE and
not XMLString::compareIString(child->getNodeName(),
str_geometry))
{
node = static_cast<DOMElement*> (child);
}
child = child->getNextSibling();
}
if (not node)
{
if (g.is_set())
{
node = n->getOwnerDocument()->createElement(str_geometry);
if (n->hasChildNodes())
n->insertBefore(node, n->getFirstChild());
else
n->appendChild(node);
}
else
return ;
}
if (not g.is_set())
n->removeChild(node);
# include <vaucanson/xml/loadgeometry.inc>
}
# undef SET_ATTR
# undef OPTION_ATTR
# undef OPTION
inline
void
if_tag<XmlInfosTag>::set_state(DOMElement* n, hstate_t s, XmlInfosTag tag)
{
if (tag.get_states().get_label()[s].is_set())
{
XMLCh* label = XMLString::transcode(tag.get_states()
.get_label()[s]().c_str());
n->setAttribute(str_label, label);
XMLString::release(&label);
}
set_default(n, tag.get_states()[s]);
}
inline
DOMElement*
if_tag<XmlInfosTag>::add_state(xml_automaton_impl_t& x,
hstate_t s, const XmlInfosTag& tag)
{
if (tag.get_states().get_name().find(s) ==
tag.get_states().get_name().end())
return x.add_state_elt(s);
else if (tag.get_states().get_name().find(s)->second == "")
return x.add_state_elt(s);
else
return x.add_state_elt(s,
tag.get_states().get_name().find(s)->second);
}
# define SET_ATTR(Section, Attr) \
if (node->hasAttribute(str_##Attr )) \
{ \
std::istringstream strs (xml2str(node->getAttribute(str_##Attr ))); \
strs >> Section () . get_##Attr ()(); \
} \
else \
Section (). get_##Attr() .is_set() = false;
# define OPTION_ATTR(Field, Attr, Do) \
if (node->hasAttribute(str_##Attr )) \
{ \
Do \
}
# define OPTION(Section, Attr, Value, Str) \
if (not XMLString::compareIString(str_##Str, \
node->getAttribute(str_##Attr ))) \
{ \
Section (). get_##Attr ()() = Value; \
}
inline
void
if_tag<XmlInfosTag>::get_default(const DOMElement* n,
XmlInfosTag::Geometry& g)
{
const DOMNode* child = n->getFirstChild();
while (child)
{
if (child->getNodeType() == DOMNode::ELEMENT_NODE and
not XMLString::compareIString(child->getNodeName(),
str_geometry))
{
const DOMElement* node =
static_cast<const DOMElement*> (child);
g.is_set() = true;
# include <vaucanson/xml/loadgeometry.inc>
return ;
}
child = child->getNextSibling();
}
g.is_set() = false;
}
# undef SET_ATTR
# undef OPTION_ATTR
# undef OPTION
inline
void
if_tag<XmlInfosTag>::get_state(const DOMElement* n,
hstate_t s,
XmlInfosTag& tag)
{
tag.get_states().get_name()[s] = xml2str(n->getAttribute(str_name));
if (n->hasAttribute(str_label))
{
tag.get_states().get_label()[s]() =
xml2str(n->getAttribute(str_label));
}
else
tag.get_states().get_label()[s].is_set() = false;
get_default(n, tag.get_states()[s]);
}
} // End of namespace xml.
} // End of namespace vcsn.
#endif // ! VCSN_XML_IF_TAG_HXX
......@@ -49,6 +49,7 @@
# include <vaucanson/design_pattern/factory.hh>
# include <vaucanson/algebra/concept/freemonoid_product.hh>
# include <vaucanson/algebra/implementation/series/krat_exp_parser.hh>
# include <vaucanson/tools/usual_macros.hh>
# include <vaucanson/xml/xml_chooser.hh>
# include <vaucanson/xml/tools.hh>
......
......@@ -46,11 +46,6 @@ namespace vcsn
std::string
xml2str(const XMLCh*);
// FIXME: We need that horror for xmlstrings.inc to work properly!
using namespace xercesc;
# include <vaucanson/xml/xmlstrings.inc>
} // End of namespace xml.
} // End of namespace vcsn.
......
......@@ -43,8 +43,10 @@
*
* @author Louis-Noel Pouchet <louis-noel.pouchet@lrde.epita.fr>
*/
# include <xercesc/dom/DOM.hpp>
# include <vaucanson/design_pattern/element.hh>
# include <vaucanson/tools/usual_macros.hh>
# include <vaucanson/boolean_automaton.hh>
# include <vaucanson/z_automaton.hh>
# include <vaucanson/z_max_plus_automaton.hh>
......
......@@ -48,7 +48,7 @@
# include <xercesc/dom/DOM.hpp>
# include <xercesc/framework/Wrapper4InputSource.hpp>
# include <vaucanson/xml/XML.hh>
# include <vaucanson/tools/usual_macros.hh>
# include <vaucanson/xml/ios.hh>
# include <vaucanson/xml/strings.hh>
# include <vaucanson/xml/error_handler.hh>
......
......@@ -47,7 +47,6 @@
# include <sstream>
# include <xercesc/dom/DOM.hpp>
# include <vaucanson/xml/tools.hh>
# include <vaucanson/design_pattern/element.hh>
# include <vaucanson/boolean_automaton.hh>
# include <vaucanson/z_automaton.hh>
......@@ -56,6 +55,8 @@
# include <vaucanson/r_automaton.hh>
# include <vaucanson/fmp_transducer.hh>
# include <vaucanson/boolean_transducer.hh>
# include <vaucanson/tools/usual_macros.hh>
# include <vaucanson/xml/tools.hh>
namespace vcsn
......
......@@ -54,9 +54,10 @@
# include <vaucanson/design_pattern/element.hh>
# include <vaucanson/design_pattern/factory.hh>
# include <vaucanson/xml/xml_chooser.hh>
# include <vaucanson/tools/usual_macros.hh>
# include <vaucanson/xml/xerces_parser.hh>
# include <vaucanson/xml/node.hh>
# include <vaucanson/xml/xml_chooser.hh>
namespace vcsn
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment