Saltar al contenido principal
Versión: Siguiente

XML SAX

SAX ADD PROCESSING INSTRUCTION ( documento : Time ; instruccion : Text )
SAX ADD XML CDATA ( documento : Time ; datos : Blob, Text )
SAX ADD XML COMMENT ( documento : Time ; comentario : Text )
SAX ADD XML DOCTYPE ( documento : Time ; docType : Text )
SAX ADD XML ELEMENT VALUE ( documento : Time ; datos : Text, Variable {; *} )
SAX CLOSE XML ELEMENT ( documento : Time )
SAX GET XML CDATA ( documento : Time ; valor : Text, Blob )
SAX GET XML COMMENT ( documento : Time ; comentario : Text )
SAX GET XML DOCUMENT VALUES ( documento : Time ; codificacion : Text ; version : Text ; autonomo : Boolean )
SAX GET XML ELEMENT ( documento : Time ; nombre : Text ; prefijo : Text ; nomsAtributos : Text array ; valoresAtributos : Text array )
SAX GET XML ELEMENT VALUE ( documento : Time ; valor : Text, Blob )
SAX GET XML ENTITY ( documento : Time ; nombre : Text ; valor : Text )
SAX Get XML node ( documento : Time ) : Integer
SAX GET XML PROCESSING INSTRUCTION ( documento : Time ; nombre : Text ; valor : Text )
SAX OPEN XML ELEMENT ( documento : Time ; etiqueta : Text {; nomAtrib : Text ; valorAtrib : Text} {; ...(nomAtrib : Text, valorAtrib : Text)} )
SAX OPEN XML ELEMENT ARRAYS ( documento : Time ; etiqueta : Text {; arrayNomsAtrib : Text array ; arrayValoresAtrib : Array} {; ...(arrayNomsAtrib : Text array, arrayValoresAtrib : Array)} )
SAX SET XML DECLARATION ( documento : Time ; codificacion : Text {; autonomo : Boolean} )

Visión general de los comandos XML SAX

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

Creación, apertura y cierre de documentos XML mediante 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. Posteriormente, el uso de un comando XML con estos documentos provocará la activación automática de mecanismos XML como la codificación. Por ejemplo, la codificación <?xml version="1.0" encoding="… encodage …" standalone = "no "?> el encabezado se escribirá automáticamente en el documento.

nota

Documents read by SAX commands must be opened in read-only mode by the Open document command. Esto evita cualquier conflicto entre 4D y la biblioteca Xerces cuando se abren documentos "normales" y XML simultáneamente. If you execute a SAX parsing command with a document open in read-write mode, an alert message is displayed and parsing is impossible.

El cierre de un documento XML debe realizarse mediante el comando CLOSE DOCUMENT. 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:

  • Caracteres CRLF en Windows y LF en macOS para los caracteres de fin de línea
  • archivos escritos sin BOM.
Compatibilidad

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.