Aller au contenu principal
Version : Suivant

XML SAX

SAX ADD PROCESSING INSTRUCTION ( document ; instruction )
SAX ADD XML CDATA ( document ; données )
SAX ADD XML COMMENT ( document ; commentaire )
SAX ADD XML DOCTYPE ( document ; docType )
SAX ADD XML ELEMENT VALUE ( document ; données {; *} )
SAX CLOSE XML ELEMENT ( document )
SAX GET XML CDATA ( document ; valeur )
SAX GET XML COMMENT ( document ; commentaire )
SAX GET XML DOCUMENT VALUES ( document ; encodage ; version ; autonome )
SAX GET XML ELEMENT ( document ; nom ; préfixe ; nomsAttributs ; valeursAttributs )
SAX GET XML ELEMENT VALUE ( document ; valeur )
SAX GET XML ENTITY ( document ; nom ; valeur )
SAX Get XML node ( document ) : Integer
SAX GET XML PROCESSING INSTRUCTION ( document ; nom ; valeur )
SAX OPEN XML ELEMENT ( document ; balise {; nomAttribut ; valeurAttribut} {; nomAttribut2 ; valeurAttribut2 ; ... ; nomAttributN ; valeurAttributN} )
SAX OPEN XML ELEMENT ARRAYS ( document ; balise {; tabNomsAttributs ; tabValeursAttributs} {; tabNomsAttributs2 ; tabValeursAttributs2 ; ... ; tabNomsAttributsN ; tabValeursAttributsN} )
SAX SET XML DECLARATION ( document ; encodage {; autonome} )

Overview of XML SAX Commands

See XML, DOM, and SAX section for a definition of XML SAX.

Creating, opening and closing XML documents via SAX

The SAX commands work with the standard document references of 4D (DocRef, a Time type reference). It is therefore possible to use these commands jointly with the 4D commands used to manage documents, such as SEND PACKET or Append document.

The creation and opening of XML documents by programming is carried out using the Create document and Open document commands. Subsequently, the use of an XML command with these documents will cause the automatic activation of XML mechanisms such as encoding. For instance, the <?xml version="1.0" encoding="… encodage …" standalone = "no "?> header will be written automatically in the document.

note

Documents read by SAX commands must be opened in read-only mode by the Open document command. This avoids any conflict between 4D and the Xerces library when you open "regular" and XML documents simultaneously. If you execute a SAX parsing command with a document open in read-write mode, an alert message is displayed and parsing is impossible.

Closing an XML document must be carried out using the CLOSE DOCUMENT command. If any XML elements were open, they will be closed automatically.

About end-of-line characters and BOM management

When writing SAX documents, 4D uses the following default settings for end-of-line characters and BOM (byte order mask) usage:

  • CRLF characters on Windows and LF on macOS for end-of-line characters
  • files are written without BOM.
Compatibilité

In projects created with 4D versions up to 19.x, by default 4D uses CRLF as end-of-line characters on macOS for SAX and a BOM. You can control the XML line ending and XML BOM management using the XML SET OPTIONS command and a Compatibility setting. Important: Since SAX file lines are written directly at each statement, if you need to set the BOM and/or end-of-line options, you must call the XML SET OPTIONS command before the first SAX writing command.