14#include "arcane/utils/NotImplementedException.h" 
   15#include "arcane/utils/Array.h" 
   16#include "arcane/utils/Iostream.h" 
   17#include "arcane/utils/ScopedPtr.h" 
   18#include "arcane/utils/StdHeader.h" 
   19#include "arcane/utils/ITraceMng.h" 
   20#include "arcane/utils/OStringStream.h" 
   21#include "arcane/utils/TraceInfo.h" 
   22#include "arcane/utils/StringBuilder.h" 
   23#include "arcane/utils/CheckedConvert.h" 
   25#include "arcane/core/Dom.h" 
   26#include "arcane/core/DomUtils.h" 
   27#include "arcane/core/ISharedReference.h" 
   28#include "arcane/core/XmlNode.h" 
   29#include "arcane/core/IXmlDocumentHolder.h" 
   30#include "arcane/core/XmlException.h" 
   32#include <libxml/tree.h> 
   33#include <libxml/parser.h> 
   34#include <libxml/xmlsave.h> 
   35#include <libxml/parserInternals.h> 
   36#include <libxml/xinclude.h> 
   37#include <libxml/xmlschemas.h> 
   74static xmlNodePtr impl(NodePrv* p) { 
return (xmlNodePtr)p; }
 
   75static xmlAttrPtr impl(AttrPrv* p) { 
return (xmlAttrPtr)p; }
 
   76static xmlElementPtr impl(ElementPrv* p) { 
return (xmlElementPtr)p; }
 
   77static xmlNamedNodeMapPtr impl(NamedNodeMapPrv* p) { 
return (xmlNamedNodeMapPtr)p; }
 
   78static xmlDocPtr impl(DocumentPrv* p) { 
return (xmlDocPtr)p; }
 
   79static xmlDocTypePtr impl(DocumentTypePrv* p) { 
return (xmlDocTypePtr)p; }
 
   81static xmlCharacterDataPtr impl(CharacterDataPrv* p) { 
return (xmlCharacterDataPtr)p; }
 
   82static xmlTextPtr impl(TextPrv* p) { 
return (xmlTextPtr)p; }
 
   83[[maybe_unused]] 
static xmlNodeListPtr impl(NodeListPrv* p) { 
return (xmlNodeListPtr)p; }
 
   84static xmlDocumentFragmentPtr impl(DocumentFragmentPrv* p) { 
return (xmlDocumentFragmentPtr)p; }
 
   85static xmlCDATAPtr impl(CDATASectionPrv* p) { 
return (xmlCDATAPtr)p; }
 
   86static xmlProcessingInstructionPtr impl(ProcessingInstructionPrv* p) { 
return (xmlProcessingInstructionPtr)p; }
 
   87static xmlEntityReferencePtr impl(EntityReferencePrv* p) { 
return (xmlEntityReferencePtr)p; }
 
   88[[maybe_unused]] 
static xmlEntityPtr impl(EntityPrv* p) { 
return (xmlEntityPtr)p; }
 
   89[[maybe_unused]] 
static xmlNotationPtr impl(NotationPrv* p) { 
return (xmlNotationPtr)p; }
 
   93static NodePrv* cvt(xmlNodePtr p) { 
return (NodePrv*)p; }
 
   94static AttrPrv* cvt(xmlAttrPtr p) { 
return (AttrPrv*)p; }
 
   95static ElementPrv* cvt(xmlElementPtr p) { 
return (ElementPrv*)p; }
 
   96static NamedNodeMapPrv* cvt(xmlNamedNodeMapPtr p) { 
return (NamedNodeMapPrv*)p; }
 
   97static DocumentPrv* cvt(xmlDocPtr p) { 
return (DocumentPrv*)p; }
 
   98static DocumentTypePrv* cvt(xmlDocTypePtr p) { 
return (DocumentTypePrv*)p; }
 
  100static CharacterDataPrv* cvt(xmlCharacterDataPtr p) { 
return (CharacterDataPrv*)p; }
 
  101static TextPrv* cvt(xmlTextPtr p) { 
return (TextPrv*)p; }
 
  102[[maybe_unused]] 
static NodeListPrv* cvt(xmlNodeListPtr p) { 
return (NodeListPrv*)p; }
 
  103[[maybe_unused]] 
static DocumentFragmentPrv* cvt(xmlDocumentFragmentPtr p) { 
return (DocumentFragmentPrv*)p; }
 
  104[[maybe_unused]] 
static CommentPrv* cvt(xmlCommentPtr p) { 
return (CommentPrv*)p; }
 
  105[[maybe_unused]] 
static CDATASectionPrv* cvt(xmlCDATAPtr p) { 
return (CDATASectionPrv*)p; }
 
  106static ProcessingInstructionPrv* cvt(xmlProcessingInstructionPtr p) { 
return (ProcessingInstructionPrv*)p; }
 
  107[[maybe_unused]] 
static EntityReferencePrv* cvt(xmlEntityReferencePtr p) { 
return (EntityReferencePrv*)p; }
 
  108static EntityPrv* cvt(xmlEntityPtr p) { 
return (EntityPrv*)p; }
 
  109static NotationPrv* cvt(xmlNotationPtr p) { 
return (NotationPrv*)p; }
 
  117domStringToXmlChar(
const String& str)
 
  119  const xmlChar* ch = 
reinterpret_cast<const xmlChar*
>(str.utf8().data());
 
  124toChar(
const String& value)
 
  126  return domStringToXmlChar(value);
 
  129String fromChar(
const xmlChar* value)
 
  136  return DOMString(bytes);
 
  139String fromCharAndFree(xmlChar* value)
 
  143  String s(fromChar(value));
 
  151NodePrv* toNodePrv(
const Node& node)
 
  162#define TNIE throw NotImplementedException(A_FUNCINFO) 
  173    return &sDOMImplementation;
 
 
  187class LibXml2_ErrorHandler
 
  191  LibXml2_ErrorHandler()
 
  195  ~LibXml2_ErrorHandler()
 
  197    ::xmlSetStructuredErrorFunc(
nullptr,
nullptr);
 
  203  static void XMLCDECL 
handler(
void* user_data,T* e)
 
  207    auto x = 
reinterpret_cast<LibXml2_ErrorHandler*
>(user_data);
 
 
  213  const String& errorMessage()
 const { 
return m_error_message; }
 
  217  void addError(
const xmlError* e)
 
  220    if (e->level==XML_ERR_WARNING)
 
  222    else if (e->level==XML_ERR_ERROR)
 
  224    else if (e->level==XML_ERR_FATAL)
 
  245    m_error_message = m_error_message + sb.
toString();
 
 
  264  : m_file_name(file_name)
 
  269    m_options = XML_PARSE_HUGE;
 
  289  const String& fileName()
 const { 
return m_file_name; }
 
  290  int options()
 const { 
return m_options; }
 
 
  309class LibXml2_SchemaValidator
 
  312  LibXml2_SchemaValidator(
const String& schema_file_name)
 
  313  : m_schema_file_name(schema_file_name),m_schema_parser_context(
nullptr),
 
  314    m_schema_ptr(
nullptr), m_schema_valid_context(
nullptr)
 
  317  ~LibXml2_SchemaValidator()
 
  334  String m_schema_file_name;
 
  335  ::xmlSchemaParserCtxtPtr m_schema_parser_context;
 
  336  ::xmlSchemaPtr m_schema_ptr;
 
  337  ::xmlSchemaValidCtxtPtr m_schema_valid_context;
 
  341    if (m_schema_parser_context){
 
  342      ::xmlSchemaFreeParserCtxt(m_schema_parser_context);
 
  343      m_schema_parser_context = 
nullptr;
 
  346      ::xmlSchemaFree(m_schema_ptr);
 
  347      m_schema_ptr = 
nullptr;
 
  349    if (m_schema_valid_context){
 
  350      ::xmlSchemaFreeValidCtxt(m_schema_valid_context);
 
  351      m_schema_valid_context = 
nullptr;
 
 
  370class LibXml2_MemoryReader
 
  375  : m_buffer(buffer) {}
 
  379    const char* encoding = 
nullptr;
 
  380    int options = parser.options();
 
  381    const char* buf_base = 
reinterpret_cast<const char*
>(m_buffer.data());
 
  386    while (buf_size > 0 && 
static_cast<char>(m_buffer[buf_size - 1]) == 
'\0') {
 
  389    const String& name = parser.fileName();
 
  390    ::xmlParserCtxtPtr ctxt = ::xmlNewParserCtxt();
 
  391    ::xmlDocPtr doc = ::xmlCtxtReadMemory(ctxt,buf_base,buf_size,
 
  393    ::xmlFreeParserCtxt(ctxt);
 
 
  403class LibXml2_FileReader
 
  407  LibXml2_FileReader(
const String& file_name)
 
  408  : m_file_name(file_name) {}
 
  412    const char* encoding = 
nullptr;
 
  413    int options = parser.options();
 
  414    const char* file_name = m_file_name.
localstr();
 
  415    ::xmlParserCtxtPtr ctxt = ::xmlNewParserCtxt();
 
  416    ::xmlDocPtr doc = ::xmlCtxtReadFile(ctxt,file_name,encoding,options);
 
  417    ::xmlFreeParserCtxt(ctxt);
 
 
  427class XmlDocumentHolderLibXml2
 
  431  XmlDocumentHolderLibXml2()
 
  432  : m_document(
nullptr), m_document_node(
nullptr)
 
  434  ~XmlDocumentHolderLibXml2()
 
  437      ::xmlDocPtr doc = impl(m_document);
 
  446    domimp._save(bytes,m_document,(-1));
 
 
  453    String new_s = String::fromUtf8(bytes);
 
 
  459  void assignDocument(DocumentPrv* doc)
 
  462    m_document_node = (NodePrv*)doc;
 
  464  DocumentPrv* _document()
 const { 
return m_document; }
 
  466  DocumentPrv* m_document;
 
  467  NodePrv* m_document_node;
 
 
  477  m_p = cvt(LibXml2_DOMImplementation::getImplementation());
 
  481DOMImplementation(ImplementationPrv* prv)
 
  491void DOMImplementation::
 
  498ImplementationPrv* DOMImplementation::
 
  504bool DOMImplementation::
 
  505hasFeature(
const DOMString& feature,
const DOMString& version)
 const 
  507  ARCANE_UNUSED(feature);
 
  508  ARCANE_UNUSED(version);
 
  515createDocumentType(
const DOMString& qualified_name,
const DOMString& public_id,
 
  516                   const DOMString& system_id)
 const 
  518  ARCANE_UNUSED(qualified_name);
 
  519  ARCANE_UNUSED(public_id);
 
  520  ARCANE_UNUSED(system_id);
 
  528getInterface(
const DOMString& feature)
 const 
  531  ARCANE_UNUSED(feature);
 
  532  throw NotImplementedException(A_FUNCINFO);
 
  536createDOMWriter()
 const 
  539  throw NotImplementedException(A_FUNCINFO);
 
  548createDocument(
const DOMString& namespace_uri,
const DOMString& qualified_name,
 
  551  if (!namespace_uri.null())
 
  552    ARCANE_THROW(NotImplementedException,
"non nul namespace-uri");
 
  553  if (!qualified_name.null())
 
  554    ARCANE_THROW(NotImplementedException,
"non nul qualified-name");
 
  555  if (!doctype._null())
 
  556    ARCANE_THROW(NotImplementedException,
"non nul doctype");
 
  557  const xmlChar* xml_version = 
nullptr;
 
  558  xmlDocPtr doc = ::xmlNewDoc(xml_version);
 
  565String DOMImplementation::
 
  566_implementationName()
 const 
  577  Document _doc = createDocument(DOMString(),DOMString(),DocumentType());
 
  578  auto xml_doc = 
new XmlDocumentHolderLibXml2();
 
  579  xml_doc->assignDocument(_doc._impl());
 
  587_load(
const String& fname,ITraceMng* msg,
const String& schemaname)
 
  596_load(
const String& fname,ITraceMng* trace,
const String& schema_name,
 
  600  LibXml2_FileReader reader(fname);
 
  601  LibXml2_Parser parser(fname,trace);
 
  602  auto doc_holder = parser.parse(&reader,schema_name,schema_data);
 
  614    return new XmlDocumentHolderLibXml2();
 
  616  LibXml2_MemoryReader reader(buffer);
 
  617  LibXml2_Parser parser(name,trace);
 
  625void DOMImplementation::
 
  628  ARCANE_UNUSED(indent_level);
 
  638  xmlDocPtr doc = impl(document._impl());
 
  639  xmlBufferPtr buf = ::xmlBufferCreate();
 
  642  if (indent_level > 0)
 
  643    options = XML_SAVE_FORMAT;
 
  644  xmlSaveCtxtPtr ctx = ::xmlSaveToBuffer(buf,
nullptr,options);
 
  645  (void)::xmlSaveDoc(ctx,doc);
 
  646  (void)::xmlSaveClose(ctx);
 
  648  const xmlChar* content = ::xmlBufferContent(buf);
 
  649  size_t content_len = ::xmlBufferLength(buf);
 
  653  bytes.copy(buf_view);
 
  655  ::xmlBufferFree(buf);
 
  667  m_options |= XML_PARSE_DTDLOAD | XML_PARSE_NOENT | XML_PARSE_DTDATTR;
 
  668  m_options |= XML_PARSE_XINCLUDE;
 
  670  ::xmlDocPtr doc_ptr = 
nullptr;
 
  677    doc_ptr = reader->read(*
this);
 
  681                   err_handler.errorMessage());
 
  684    xml_parser->assignDocument(cvt(doc_ptr));
 
  688    int nb_xinclude = ::xmlXIncludeProcess(doc_ptr);
 
  689    if (nb_xinclude==(-1))
 
  691                   err_handler.errorMessage());
 
  695    String err_message = err_handler.errorMessage();
 
  696    if (m_trace && !err_message.
null())
 
  697      m_trace->info() << 
"Info parsing document " << fileName() << 
" : " << err_message;
 
  705    validator.
validate(doc_ptr,schema_data);
 
  708  return xml_parser.release();
 
 
  720  if (m_schema_file_name.null() && schema_data.
empty())
 
  724  if (!schema_data.
empty()){
 
  725    auto base_ptr = 
reinterpret_cast<const char*
>(schema_data.
data());
 
  726    m_schema_parser_context = ::xmlSchemaNewMemParserCtxt(base_ptr,schema_data.
size());
 
  729    m_schema_parser_context = ::xmlSchemaNewParserCtxt(m_schema_file_name.localstr());
 
  730  if (!m_schema_parser_context)
 
  732  m_schema_ptr = xmlSchemaParse(m_schema_parser_context);
 
  735                 err_handler.errorMessage());
 
  736  m_schema_valid_context = xmlSchemaNewValidCtxt(m_schema_ptr);
 
  737  if (!m_schema_valid_context)
 
  739                 m_schema_file_name,err_handler.errorMessage());
 
  740  xmlSchemaSetValidOptions(m_schema_valid_context, XML_SCHEMA_VAL_VC_I_CREATE);
 
  741  int result = xmlSchemaValidateDoc(m_schema_valid_context, doc_ptr);
 
  744                 m_schema_file_name,err_handler.errorMessage());
 
 
  763Node(
const Node& from)
 
  768operator=(
const Node& from)
 
  799  return (UShort)(impl(
m_p)->type);
 
  805  ::xmlNodePtr first_children = impl(
m_p)->children;
 
  806  return cvt(first_children);
 
  816previousSibling()
 const 
  826  xmlNodePtr next_node = impl(
m_p)->next;
 
  827  return cvt(next_node);
 
  833  return cvt(impl(
m_p)->parent);
 
  848  return fromChar(impl(
m_p)->name);
 
  854  ::xmlNodePtr xelement = impl(
m_p);
 
  855  xmlAttrPtr p = xelement->properties;
 
  856  return cvt((xmlNamedNodeMapPtr)(p));
 
  862  ::xmlNodePtr node = impl(
m_p);
 
  863  return cvt(node->doc);
 
  869  xmlChar* content = ::xmlNodeGetContent(impl(
m_p));
 
  870  return fromCharAndFree(content);
 
  873nodeValue(
const DOMString& str)
 const 
  881_assign(
const Node& node)
 
  886insertBefore(
const Node& new_child,
const Node& ref_child)
 const 
  888  ARCANE_UNUSED(new_child);
 
  889  ARCANE_UNUSED(ref_child);
 
  895replaceChild(
const Node& new_child,
const Node& old_child)
 const 
  897  ARCANE_UNUSED(new_child);
 
  898  ARCANE_UNUSED(old_child);
 
  904removeChild(
const Node& old_child)
 const 
  907  ::xmlNodePtr xchild = impl(old_child._impl());
 
  910  ::xmlUnlinkNode(xchild);
 
  914appendChild(
const Node& new_child)
 const 
  917  return cvt(::xmlAddChild(impl(
m_p),impl(new_child._impl())));
 
  927cloneNode(
bool deep)
 const 
  942prefix(
const DOMString& new_prefix)
 const 
  945  ARCANE_UNUSED(new_prefix);
 
  957isSupported(
const DOMString& feature,
const DOMString& version)
 const 
  959  ARCANE_UNUSED(feature);
 
  960  ARCANE_UNUSED(version);
 
  976  return fromChar(impl(
m_p)->name);
 
  993textContent(
const DOMString& value)
 const 
  996  ARCANE_UNUSED(value);
 
 1001isSameNode(
const Node& node)
 const 
 1004  ARCANE_UNUSED(node);
 
 1009isEqualNode(
const Node& other)
 const 
 1012  ARCANE_UNUSED(other);
 
 1017isDefaultNamespace(
const DOMString& namespace_uri)
 const 
 1020  ARCANE_UNUSED(namespace_uri);
 
 1025lookupNamespaceURI(
const DOMString& prefix)
 const 
 1028  ARCANE_UNUSED(prefix);
 
 1033setUserData(
const DOMString& key,
const DOMObject& data,
 
 1038  ARCANE_UNUSED(data);
 
 1039  ARCANE_UNUSED(handler);
 
 1040  throw NotImplementedException(A_FUNCINFO);
 
 1043getUserData(
const DOMString& key)
 const 
 1053  ::xmlNodePtr xnode = impl(
m_p);
 
 1055    ::xmlFreeNode(xnode);
 
 
 1058operator==(
const Node& n1,
const Node& n2)
 
 1060  return impl(n1.
m_p) == impl(n2.
m_p);
 
 1063operator!=(
const Node& n1,
const Node& n2)
 
 1065  return ! operator==(n1,n2);
 
 1072CharacterData(CharacterDataPrv* v)
 
 1073: Node(cvt((xmlNodePtr)impl(v)))
 
 1088CharacterData(
const Node& node)
 
 1092  ARCANE_UNUSED(node);
 
 1098CharacterDataPrv* CharacterData::
 
 1117Text(
const Text& node)
 
 1122Text(
const Node& node)
 
 1126  ARCANE_UNUSED(node);
 
 1134  return cvt((xmlTextPtr)impl(
m_p));
 
 1153Document(DocumentPrv* p)
 
 1154: 
Node(cvt((xmlNodePtr)impl(p)))
 
 1157Document(
const Node& node)
 
 1160  NodePrv* ni= node._impl();
 
 1161  if (ni && impl(ni)->type==XML_DOCUMENT_NODE)
 
 1164DocumentPrv* Document::
 
 1167  return cvt((xmlDocPtr)impl(
m_p));
 
 1177implementation()
 const 
 1184documentElement()
 const 
 1187  xmlDocPtr xdoc = impl(_impl());
 
 1188  xmlNodePtr xnode = ::xmlDocGetRootElement(xdoc);
 
 1189  return cvt((xmlElementPtr)xnode);
 
 1192createElement(
const DOMString& name)
 const 
 1195  xmlDocPtr xdoc = impl(_impl());
 
 1196  xmlNsPtr nspace = 
nullptr;
 
 1197  xmlChar* content = 
nullptr;
 
 1198  xmlNodePtr xnode = ::xmlNewDocNode(xdoc,nspace,toChar(name),content);
 
 1199  return cvt((xmlElementPtr)xnode);
 
 1202createDocumentFragment()
 const 
 1209createTextNode(
const DOMString& data)
 const 
 1212  xmlDocPtr xdoc = impl(_impl());
 
 1213 return cvt((xmlTextPtr)::xmlNewDocText(xdoc,toChar(data)));
 
 1216createComment(
const DOMString& data)
 const 
 1220  ARCANE_UNUSED(data);
 
 1224createCDATASection(
const DOMString& data)
 const 
 1228  ARCANE_UNUSED(data);
 
 1232createProcessingInstruction(
const DOMString& target,
 
 1233                            const DOMString& data)
 const 
 1236  ARCANE_UNUSED(target);
 
 1237  ARCANE_UNUSED(data);
 
 1243createAttribute(
const DOMString& name)
 const 
 1246  ARCANE_UNUSED(name);
 
 1252createEntityReference(
const DOMString& name)
 const 
 1255  ARCANE_UNUSED(name);
 
 1260getElementsByTagName(
const DOMString& tagname)
 const 
 1263  ARCANE_UNUSED(tagname);
 
 1268importNode(
const Node& imported_node,
bool deep)
 const 
 1271  ARCANE_UNUSED(imported_node);
 
 1272  ARCANE_UNUSED(deep);
 
 1277createElementNS(
const DOMString& namespace_uri,
const DOMString& qualified_name)
 const 
 1280  ARCANE_UNUSED(namespace_uri);
 
 1281  ARCANE_UNUSED(qualified_name);
 
 1286createAttributeNS(
const DOMString& namespace_uri,
const DOMString& qualified_name)
 const 
 1289  ARCANE_UNUSED(namespace_uri);
 
 1290  ARCANE_UNUSED(qualified_name);
 
 1295getElementsByTagNameNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 1298  ARCANE_UNUSED(namespace_uri);
 
 1299  ARCANE_UNUSED(local_name);
 
 1304getElementById(
const DOMString& element_id)
 const 
 1308  ARCANE_UNUSED(element_id);
 
 1312actualEncoding()
 const 
 1319actualEncoding(
const DOMString& value)
 const 
 1322  ARCANE_UNUSED(value);
 
 1323  throw NotImplementedException(A_FUNCINFO);
 
 1330  throw NotImplementedException(A_FUNCINFO);
 
 1334encoding(
const DOMString& value)
 const 
 1337  ARCANE_UNUSED(value);
 
 1338  throw NotImplementedException(A_FUNCINFO);
 
 1345  throw NotImplementedException(A_FUNCINFO);
 
 1349standalone(
bool value)
 const 
 1352  ARCANE_UNUSED(value);
 
 1353  throw NotImplementedException(A_FUNCINFO);
 
 1357strictErrorChecking()
 const 
 1364strictErrorChecking(
bool value)
 const 
 1367  ARCANE_UNUSED(value);
 
 1372documentURI(
const DOMString& document_uri)
 const 
 1375  ARCANE_UNUSED(document_uri);
 
 1388adoptNode(
const Node& source)
 const 
 1392  ARCANE_UNUSED(source);
 
 1403renameNode(
const Node& node,
const DOMString& namespace_uri,
 
 1404           const DOMString& name)
 
 1408  ARCANE_UNUSED(node);
 
 1409  ARCANE_UNUSED(namespace_uri);
 
 1410  ARCANE_UNUSED(name);
 
 1423DocumentFragment(DocumentFragmentPrv* prv)
 
 1424: 
Node(cvt((xmlNodePtr)impl(prv)))
 
 1435Comment(CommentPrv* prv)
 
 1447CDATASection(CDATASectionPrv* prv)
 
 1448: 
Text(cvt((xmlTextPtr)impl(prv)))
 
 1459EntityReference(EntityReferencePrv* prv)
 
 1460: 
Node(cvt((xmlNodePtr)impl(prv)))
 
 1471NodeList(NodeListPrv* prv)
 
 1482item(ULong index)
 const 
 1485  ARCANE_UNUSED(index);
 
 1500DOMString CharacterData::
 
 1508data(
const DOMString& value)
 const 
 1511  ARCANE_UNUSED(value);
 
 1515ULong CharacterData::
 
 1522DOMString CharacterData::
 
 1523substringData(ULong offset,ULong count)
 const 
 1526  ARCANE_UNUSED(offset);
 
 1527  ARCANE_UNUSED(count);
 
 1532appendData(
const DOMString& arg)
 const 
 1540insertData(ULong offset,
const DOMString& arg)
 const 
 1543  ARCANE_UNUSED(offset);
 
 1549deleteData(ULong offset,ULong count)
 const 
 1552  ARCANE_UNUSED(offset);
 
 1553  ARCANE_UNUSED(count);
 
 1558replaceData(ULong offset,ULong count,
const DOMString& arg)
 const 
 1562  ARCANE_UNUSED(offset);
 
 1563  ARCANE_UNUSED(count);
 
 1573: 
Node(cvt((xmlNodePtr)impl(p)))
 
 1578Attr(
const Node& node)
 
 1581  ARCANE_UNUSED(node);
 
 1591  return cvt((xmlAttrPtr)impl(
m_p));
 
 1615value(
const DOMString& str)
 const 
 1638Element(ElementPrv* p)
 
 1639: 
Node(cvt((xmlNodePtr)impl(p)))
 
 1642Element(
const Node& node)
 
 1645  NodePrv* ni= node._impl();
 
 1646  if (ni && impl(ni)->type==XML_ELEMENT_NODE)
 
 1653ElementPrv* Element::
 
 1656  return cvt((xmlElementPtr)impl(
m_p));
 
 1667getAttribute(
const DOMString& name)
 const 
 1670  Attr a = getAttributeNode(name);
 
 1673  ::xmlChar* prop = ::xmlGetProp(impl(
m_p),toChar(name));
 
 1674  String s = fromChar(prop);
 
 1679setAttribute(
const DOMString& name,
const DOMString& value)
 const 
 1682  ::xmlSetProp(impl(
m_p),toChar(name),toChar(value));
 
 1685removeAttribute(
const DOMString& name)
 const 
 1688  ARCANE_UNUSED(name);
 
 1693getAttributeNode(
const DOMString& name)
 const 
 1696  xmlElementPtr elem_ptr = (xmlElementPtr)(impl(_impl()));
 
 1697  return cvt(::xmlHasProp((xmlNodePtr)elem_ptr,toChar(name)));
 
 1700setAttributeNode(
const Attr& new_attr)
 const 
 1703  ARCANE_UNUSED(new_attr);
 
 1708removeAttributeNode(
const Attr& old_attr)
 const 
 1711  ARCANE_UNUSED(old_attr);
 
 1716getElementsByTagName(
const DOMString& name)
 const 
 1719  ARCANE_UNUSED(name);
 
 1724getAttributeNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 1727  ARCANE_UNUSED(namespace_uri);
 
 1728  ARCANE_UNUSED(local_name);
 
 1733setAttributeNS(
const DOMString& namespace_uri,
const DOMString& local_name,
 
 1734               const DOMString& value)
 const 
 1737  ARCANE_UNUSED(namespace_uri);
 
 1738  ARCANE_UNUSED(local_name);
 
 1739  ARCANE_UNUSED(value);
 
 1744removeAttributeNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 1747  ARCANE_UNUSED(namespace_uri);
 
 1748  ARCANE_UNUSED(local_name);
 
 1753getAttributeNodeNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 1756  ARCANE_UNUSED(namespace_uri);
 
 1757  ARCANE_UNUSED(local_name);
 
 1762setAttributeNodeNS(
const Attr& new_attr)
 const 
 1765  new_attr._checkValid();
 
 1770getElementsByTagNameNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 1773  ARCANE_UNUSED(namespace_uri);
 
 1774  ARCANE_UNUSED(local_name);
 
 1779hasAttribute(
const DOMString& name)
 const 
 1782  ARCANE_UNUSED(name);
 
 1787hasAttributeNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 1790  ARCANE_UNUSED(namespace_uri);
 
 1791  ARCANE_UNUSED(local_name);
 
 1800splitText(ULong offset)
 const 
 1803  ARCANE_UNUSED(offset);
 
 1815replaceWholeText(
const DOMString& content)
 const 
 1818  ARCANE_UNUSED(content);
 
 1831DocumentType(DocumentTypePrv* prv)
 
 1832: 
Node(cvt((xmlNodePtr)impl(prv)))
 
 1834DocumentTypePrv* DocumentType::
 
 1837  return cvt((xmlDocTypePtr)impl(
m_p));
 
 1839DOMString DocumentType::
 
 1860DOMString DocumentType::
 
 1867DOMString DocumentType::
 
 1874DOMString DocumentType::
 
 1875internalSubset()
 const 
 1885NotationPrv* Notation::
 
 1888  return cvt((xmlNotationPtr)impl(
m_p));
 
 1913  return cvt((xmlEntityPtr)impl(
m_p));
 
 1941ProcessingInstruction::
 
 1942ProcessingInstruction()
 
 1945ProcessingInstruction::
 
 1946ProcessingInstruction(ProcessingInstructionPrv* prv)
 
 1947: 
Node(cvt((xmlNodePtr)impl(prv)))
 
 1949ProcessingInstructionPrv* ProcessingInstruction::
 
 1952  return cvt((xmlProcessingInstructionPtr)impl(
m_p));
 
 1955DOMString ProcessingInstruction::
 
 1962DOMString ProcessingInstruction::
 
 1969void ProcessingInstruction::
 
 1970data(
const DOMString& value)
 const 
 1973  ARCANE_UNUSED(value);
 
 1986NamedNodeMap(NamedNodeMapPrv* p)
 
 2002NamedNodeMapPrv* NamedNodeMap::
 
 2018  ::xmlNodePtr xnode = (::xmlNodePtr)impl(m_p);
 
 2021    xnode = xnode->next;
 
 2026getNamedItem(
const DOMString& name)
 const 
 2037  ::xmlAttrPtr xattrlist = (::xmlAttrPtr)impl(m_p);
 
 2038  const ::xmlChar* aname = toChar(name);
 
 2039  ::xmlAttrPtr current = xattrlist;
 
 2041    if (current->type==XML_ATTRIBUTE_NODE && current->ns){
 
 2042      std::string full_name = (
const char*)(current->ns->prefix);
 
 2044      full_name += (
const char*)(current->name);
 
 2045      if (xmlStrEqual(aname, (
const xmlChar*)full_name.c_str())==1){
 
 2046        return cvt((::xmlNodePtr)current);
 
 2049    if (xmlStrEqual(aname,current->name)==1){
 
 2050      return cvt((::xmlNodePtr)current);
 
 2052    current = current->next;
 
 2057setNamedItem(
const Node& arg)
 const 
 2059  if (_null() || arg._null())
 
 2065removeNamedItem(
const DOMString& name)
 const 
 2069  ARCANE_UNUSED(name);
 
 2074item(ULong index)
 const 
 2079  ::xmlNodePtr xnode = (::xmlNodePtr)impl(m_p);
 
 2082      return Node(cvt(xnode));
 
 2084    xnode = xnode->next;
 
 2089getNamedItemNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 2093  ARCANE_UNUSED(namespace_uri);
 
 2094  ARCANE_UNUSED(local_name);
 
 2099setNamedItemNS(
const Node& arg)
 const 
 2109removeNamedItemNS(
const DOMString& namespace_uri,
const DOMString& local_name)
 const 
 2113  ARCANE_UNUSED(namespace_uri);
 
 2114  ARCANE_UNUSED(local_name);
 
 2123getDOMImplementation(
const DOMString& features)
 const 
 2125  ARCANE_UNUSED(features);
 
 2126  throw NotImplementedException(A_FUNCINFO);
 
 2132void UserDataHandler::
 
 2133handle(UShort operation,
const DOMString& key,
const DOMObject& data,
 
 2134       const Node& src,
const Node& dest)
 const 
 2136  ARCANE_UNUSED(operation);
 
 2138  ARCANE_UNUSED(data);
 
 2140  ARCANE_UNUSED(dest);
 
 2141  throw NotImplementedException(A_FUNCINFO);
 
 2152DOMWriter(DOMWriterPrv* p)
 
 2181DOMWriterPrv* DOMWriter::
 
 2188writeNode(
const Node& node)
 const 
 2190  ARCANE_UNUSED(node);
 
 2191  throw NotImplementedException(A_FUNCINFO);
 
 2195encoding(
const String& encoding)
 
 2198  ARCANE_UNUSED(encoding);
 
 2199  throw NotImplementedException(A_FUNCINFO);
 
 2206  throw NotImplementedException(A_FUNCINFO);
 
 2217DOMError(DOMErrorPrv* p)
 
 2246DOMErrorPrv* DOMError::
 
 2267relatedException()
 const 
 2284bool DOMErrorHandler::
 
 2285handleError(
const DOMError& error)
 const 
 2287  ARCANE_UNUSED(error);
 
 2288  throw NotImplementedException(A_FUNCINFO);
 
 2299DOMLocator(DOMLocatorPrv* p)
 
 2328DOMLocatorPrv* DOMLocator::
 
 2350DOMString DOMLocator::
 
 2365createExpression(
const DOMString& expression, 
 
 2368  ARCANE_UNUSED(expression);
 
 2369  ARCANE_UNUSED(resolver);
 
 2370  throw NotImplementedException(A_FUNCINFO);
 
 2375  throw NotImplementedException(A_FUNCINFO);
 
 2378createNSResolver(
const Node& node_resolver)
 const 
 2380  ARCANE_UNUSED(node_resolver);
 
 2381  throw NotImplementedException(A_FUNCINFO);
 
 2384evaluate(
const DOMString& expression,
const Node& context_node,
 
 2388  ARCANE_UNUSED(expression);
 
 2389  ARCANE_UNUSED(context_node);
 
 2390  ARCANE_UNUSED(resolver);
 
 2391  ARCANE_UNUSED(type);
 
 2392  ARCANE_UNUSED(result);
 
 2393  throw NotImplementedException(A_FUNCINFO);
 
 2397                   const Node& context_node,UShort type,
 
 2400  ARCANE_UNUSED(expression);
 
 2401  ARCANE_UNUSED(context_node);
 
 2402  ARCANE_UNUSED(type);
 
 2403  ARCANE_UNUSED(result);
 
 2404  throw NotImplementedException(A_FUNCINFO);
 
 2410DOMString XPathNSResolver::
 
 2411lookupNamespaceURI(
const DOMString& prefix)
 const 
 2413  ARCANE_UNUSED(prefix);
 
 2414  throw NotImplementedException(A_FUNCINFO);
 
 2423  throw NotImplementedException(A_FUNCINFO);
 
 2428  throw NotImplementedException(A_FUNCINFO);
 
 2430DOMString XPathResult::
 
 2433  throw NotImplementedException(A_FUNCINFO);
 
 2438  throw NotImplementedException(A_FUNCINFO);
 
 2441singleNodeValue()
 const 
 2443  throw NotImplementedException(A_FUNCINFO);
 
 2446getSetIterator(
bool ordered)
 const 
 2448  ARCANE_UNUSED(ordered);
 
 2449  throw NotImplementedException(A_FUNCINFO);
 
 2452getSetSnapshot(
bool ordered)
 const 
 2454  ARCANE_UNUSED(ordered);
 
 2455  throw NotImplementedException(A_FUNCINFO);
 
 2461Node XPathSetIterator::
 
 2464  throw NotImplementedException(A_FUNCINFO);
 
 2470ULong XPathSetSnapshot::
 
 2473  throw NotImplementedException(A_FUNCINFO);
 
 2475Node XPathSetSnapshot::
 
 2476item(ULong index)
 const 
 2478  ARCANE_UNUSED(index);
 
 2479  throw NotImplementedException(A_FUNCINFO);
 
 2488  throw NotImplementedException(A_FUNCINFO);
 
 2494void DOMImplementation::
 
 2509void DOMImplementation::
 
 2515  ::xmlCleanupParser();
 
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
constexpr const_pointer data() const noexcept
Pointeur sur la mémoire allouée.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
constexpr bool empty() const noexcept
true si le tableau est vide (size()==0)
Interface du gestionnaire de traces.
Gestionnaire d'un document DOM.
Constructeur de chaîne de caractère unicode.
String toString() const
Retourne la chaîne de caractères construite.
Chaîne de caractères unicode.
bool null() const
Retourne true si la chaîne est nulle.
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
Exception liées aux fichiers XML.
IXmlDocumentHolder * _load(const String &fname, ITraceMng *msg, const String &schemaname)
IXmlDocumentHolder * _newDocument()
Les méthodes suivantes sont internes à Arcane.
Gestion des erreurs du lecteur Xml.
static void XMLCDECL handler(void *user_data, T *e)
Handler à connecter à la libxml2.
Classe encapsulant l'analyser d'un document XML.
IXmlDocumentHolder * parse(ILibXml2_Reader *reader, const String &schema_name, ByteConstArrayView schema_data)
Analyse le contenu Xml via le reader reader.
Classe encapsulant la validation XML Schema d'un document XML.
void validate(::xmlDocPtr doc, ByteConstArrayView schema_data)
Valide un document XML.
NodePrv * m_p
Implémentation de la classe.
void releaseNode()
Détruit le noeud.
IXmlDocumentHolder * clone() override
Clone ce document.
XmlNode documentNode() override
Noeud document. Ce noeud est nul si le document n'existe pas.
String save() override
Sauvegarde ce document et retourne la chaîne de caractères.
void save(ByteArray &bytes) override
Sauvegarde ce document dans le tableau bytes.
Integer len(const char *s)
Retourne la longueur de la chaîne s.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
Integer arcaneCheckArraySize(unsigned long long size)
Vérifie que size peut être converti dans un 'Integer' pour servir de taille à un tableau....
void arcaneNullPointerError()
Signalue l'utilisation d'un pointeur nul.
Int32 Integer
Type représentant un entier.
Array< Byte > ByteArray
Tableau dynamique à une dimension de caractères.
UniqueArray< Byte > ByteUniqueArray
Tableau dynamique à une dimension de caractères.
Span< const std::byte > ByteConstSpan
Vue en lecture seule d'un tableau à une dimension de caractères.
ConstArrayView< Byte > ByteConstArrayView
Equivalent C d'un tableau à une dimension de caractères.
unsigned char Byte
Type d'un octet.