Accesso a DocTypeDecl in un messaggio XML

La dichiarazione tipo documento XML include l'elemento di sintassi DocTypeDecl e i relativi discendenti. Insieme costituiscono la struttura DOCTYPE.

I discendenti, alcuni dei quali con attributi, sono elencati di seguito insieme ai nomi di correlazione per ogni elemento di sintassi XML. Per ulteriori informazioni circa tutti questi elementi, consultare Dichiarazione del tipo documento XML.

Elemento sintassi Nome di correlazione
AttributeDef (XML.AttributeDef)
AttributeDefDefaultType (XML.AttributeDefDefaultType)
AttributeDefType (XML.AttributeDefType)
AttributeDefValue (XML.AttributeDefValue)
AttributeList (XML.AttributeList)
DocTypeComment (XML.DocTypeComment)
DocTypeDecl (XML.DocTypeDecl)
DocTypePI (XML.DocTypePI)
DocTypeWhiteSpace (XML.DocTypeWhiteSpace)
ElementDef (XML.ElementDef)
EntityDecl (XML.EntityDecl)
EntityDeclValue (XML.EntityDeclValue)
ExternalEntityDecl (XML.ExternalEntityDecl)
ExternalParameterEntityDecl (XML.ExternalParameterEntityDecl)
IntSubset (XML.IntSubset)
NotationDecl (XML.NotationDecl)
NotationReference (XML.NotationReference)
ParameterEntityDecl (XML.ParameterEntityDecl)
PublicId (XML.PublicId)
SystemId (XML.SystemId)
UnparsedEntityDecl (XML.UnparsedEntityDecl)

Le seguenti sezioni di ESQL mostrano come creare contenuto DocTypeDecl in un messaggio di output generato dal nodo Compute. E' possibile utilizzare anche gli stessi nomi di correlazione per interrogare tutti questi elementi all'interno di un messaggio XML di input.

Il primo esempio mostra DocTypeDecl e NotationDecl:
-- Creare una dichiarazione DocType denominata 'test' 
SET OutputRoot.XML.(XML.DocTypeDecl)test = '';

-- Impostare un ID di sistema e pubblico per la dichiarazione DocType
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.SystemId) 
	= 'test.dtd'; 
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.PublicId) 
	= '//this/is/a/URI/test';

-- Creare una serie secondaria interna per conservare le definizioni DTD
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset) = '';

-- Creare una dichiarazione Notation denominata 'TeX'
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.NotationDecl)TeX = '';

-- La dichiarazione Notation contiene un SystemId e un PublicId
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.NotationDecl)TeX.(XML.SystemId) = '//TexID';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.NotationDecl)TeX.(XML.PublicId) 
	= '//this/is/a/URI/TexID';

La seguente sezione mostra come impostare le entità:

-- Creare una dichiarazione Entity denominata 'ent1'
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.EntityDecl)ent1 = '';

-- Questa deve contenere un valore per la dichiarazione Entity
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.EntityDecl)ent1.(XML.EntityDeclValue) 
	= 'this is an entity';

-- Similmente per una dichiarazione Parameter Entity
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ParameterEntityDecl)ent2 = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ParameterEntityDecl)ent2.(XML.EntityDeclValue) 
	='#PCDATA | subel2';

-- Creare entrambi i tipi di External Entity, ciascuna con 
-- un ID di sistema e pubblico
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ExternalParameterEntityDecl)extent1 = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ExternalParameterEntityDecl)extent1.(XML.SystemId) 
	= 'more.txt';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ExternalParameterEntityDecl)extent1.(XML.PublicId) 
	= '//this/is/a/URI/extent1';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ExternalEntityDecl)extent2 = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ExternalEntityDecl)extent2.(XML.SystemId) 
	= 'more.txt';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ExternalEntityDecl)extent2.(XML.PublicId) 
	= '//this/is/a/URI/extent2';

-- Creare una dichiarazione Unparsed Entity denominata 'unpsd'
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.UnparsedEntityDecl)unpsd = '';
-- Questa ha un riferimento SystemId, PublicId e Notation
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.UnparsedEntityDecl).(XML.SystemId) = 'me.gif'; 
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.UnparsedEntityDecl).(XML.PublicId) 
	= '//this/is/a/URI/me.gif';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.UnparsedEntityDecl).(XML.NotationReference) = 'TeX';

La sezione di seguito mostra DocTypeWhiteSpace, DocTypeProcessingInstruction e DocTypeComment:

-- Creare alcuni spazi nella dichiarazione DocType
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.DocTypeWhiteSpace) = '      '; 

-- Creare un'istruzione di elaborazione denominata 'test'
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.DocTypePI)test = 'Do this';

-- Aggiungere un DocTypeComment
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.DocTypeComment) = 'this is a comment'; 

La seguente sezione mostra come impostare gli elementi:

-- Creare diversi elementi

SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
(XML.ElementDef)subel2 = '(#PCDATA)';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.ElementDef)subel1 = '(subel2 | el4)+';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.ElementDef)el1 = '(#PCDATA)';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.ElementDef)el2 = '(#PCDATA | subel2)*';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.ElementDef)el3 = '(#PCDATA | subel2)*';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.ElementDef)el4 = '(#PCDATA)';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.ElementDef)el5 = '(#PCDATA | subel1)*';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.ElementDef)el6 = '(#PCDATA)';

La seguente sezione mostra come impostare gli elenchi di attributi:

-- Creare un AttributeList per l'elemento subel1

SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)subel1 = '';

-- Creare un attributo denominato 'size' con valori 
-- enumerati 'big' o 'small'
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)subel1.(XML.AttributeDef)size = '';

SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)subel1.(XML.AttributeDef)size.
(XML.AttributeDefType) = '(big | small)';

-- Impostare il valore predefinito dell'attributo su 'big'
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)subel1.(XML.AttributeDef)size.
(XML.AttributeDefValue) = 'big';

-- Creare un altro attributo - questa volta si specifica 
-- DefaultType come #REQUIRED
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)subel1.(XML.AttributeDef)shape = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)subel1.(XML.AttributeDef)shape.
(XML.AttributeDefType) = '(round | square)';

-- Creare un altro elenco di attributi per l'elemento el5 con 
-- un attributo, che contenga CDATA che sia #IMPLIED
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)el5 = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)el5.(XML.AttributeDef)el5satt = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).	
	(XML.AttributeList)el5.(XML.AttributeDef)el5satt.
(XML.AttributeDefType)CDATA = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.IntSubset).
	(XML.AttributeList)el5.(XML.AttributeDef)el5satt.
(XML.AttributeDefDefaultType) = 'IMPLIED';

Si genera la seguente dichiarazione DocType (si noti che i ritorni a capo sono stati aggiunti per facilitare la visualizzazione):

<!DOCTYPE test PUBLIC "//this/is/a/URI/test" "test.dtd" 
[<!NOTATION TeX  PUBLIC "//this/is/a/URI/TexID" "//TexID">
<!ENTITY ent1 "this is an entity">
<!ENTITY % ent2 "#PCDATA | subel2">
<!ENTITY % extent1 PUBLIC "//this/is/a/URI/extent1" "more.txt">
<!ENTITY extent2 PUBLIC "//this/is/a/URI/extent2" "more.txt">
<!ENTITY unpsd PUBLIC "//this/is/a/URI/me.gif" "me.gif" NDATA TeX>	<?test Do this?>
<!--this is a comment-->
<!ELEMENT subel2 (#PCDATA)>
<!ELEMENT subel1 (subel2 | el4)+>
<!ELEMENT el1 (#PCDATA)>
<!ELEMENT el2 (#PCDATA | subel2)*>
<!ELEMENT el3 (#PCDATA | subel2)*>
<!ELEMENT el4 (#PCDATA)>
<!ELEMENT el5 (#PCDATA | subel1)*>
<!ELEMENT el6 (#PCDATA)>
<!ATTLIST subel1 
    size (big | small) "big" 
    shape (round | square) #REQUIRED>
<!ATTLIST el5 
    el5satt CDATA #IMPLIED>
]>
Concetti correlati
Panoramica dei flussi di messaggi
Panoramica di ESQL
Creazione di modelli di messaggio
Attività correlate
Progettazione di un flusso di messaggi
Definizione del contenuto del flusso di messaggi
Gestione dei file ESQL
Riferimenti correlati
Nodo Compute
Nodo Database
Nodo Filter
Riferimento ESQL
Istruzione SET
Informazioni particolari | Marchi | Download | Libreria | Supporto | Commenti
Copyright IBM Corporation 1999, 2006 Ultimo aggiornamento: ago 17, 2006
ac17320_