Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Nomi tag ripetuti in DTD XML

    Salve a tutti,
    sto cercando di realizzare un DTD di validazione per un file XML ma mi sto trovando di fronte a un problema. In pratica l'XML è strutturato così:

    <root>
    <batches>
    <batch batchcode="7107" codart="0098" expdate="" prodate="">
    <ingrs>
    <ingr code="LATTE" extbatchcode="M88" main="1" source="Paperopoli" qty=""/>
    </ingrs>
    </batches>
    <products>
    <ingrs>
    <ingr code="LATTE" type="" description="LATTE" description_EN="COW'S MILK"/>
    </ingrs>
    </products>

    Il blocco <products contiene la definizione di un prodotto, <batches rappresenta i lotti di produzione.

    Il problema è che sia in <products che in <batches io ho il blocco <ingrs e poi il tag <ingr

    In DTD questa differenza come può essere rappresentata ? Come vedete dentro <ingr ci sono degli attributi diversi a seconda che ci sitrovi in <products o <batches.

    Il mio DTD (creato con Stylus studio) che si presenta così:
    <!ELEMENT batches (batch)>
    <!ELEMENT ingr EMPTY>
    <!ATTLIST ingr
    code CDATA #REQUIRED
    extbatchcode CDATA ""
    main CDATA ""
    source CDATA ""
    qty CDATA ""
    type CDATA ""
    <!ELEMENT ingrs (ingr)+>

    non c'è cioè nessuna differenziazione...
    Qualcuno di voi può suggerirmi come risolvere la cosa ?

    Grazie in anticipo per le eventuali risposte
    Newcomsas

  2. #2
    certe validazioni io le faccio in relaxng http://relaxng.org/ si scrive + o - cosi...

    si lascia validare in javascripts o in C++ o in PHP5

    tratto dal editore XML online http://bitfluxeditor.org/ per definire strutture xhtml o altri rss ecc...

    codice:
    <?xml version="1.0" encoding="iso-8859-1"?>
    
    <grammar ns="http://www.w3.org/1999/xhtml" xmlns="http://relaxng.org/ns/structure/1.0">
    
    <define name="table">
      <element name="table">
        <ref name="table.attlist"/>
        <optional>
          <ref name="caption"/>
    	  <ref name="tbody"/>
        </optional>
        <oneOrMore>
          <ref name="tr"/>
        </oneOrMore>
      </element>
    </define>
    
    <define name="table.attlist">
      <ref name="Common.attrib"/>
      <optional>
        <attribute name="summary">
          <ref name="Text.datatype"/>
        </attribute>
      </optional>
    </define>
    
    <define name="caption">
      <element name="caption">
        <ref name="caption.attlist"/>
        <ref name="Inline.model"/>
      </element>
    </define>
    
    <define name="caption.attlist">
      <ref name="Common.attrib"/>
    </define>
    
    <define name="tr">
      <element name="tr">
        <ref name="tr.attlist"/>
        <oneOrMore>
          <choice>
            <ref name="th"/>
            <ref name="td"/>
          </choice>
        </oneOrMore>
      </element>
    </define>
    
    <define name="tr.attlist">
      <ref name="Common.attrib"/>
      <ref name="CellHAlign.attrib"/>
      <ref name="CellVAlign.attrib"/>
    </define>
    
    <define name="th">
      <element name="th">
        <ref name="th.attlist"/>
        <ref name="Flow.model"/>
      </element>
    </define>
    
    <define name="th.attlist">
      <ref name="Cell.attrib"/>
    </define>
    
    <define name="td">
      <element name="td">
        <ref name="td.attlist"/>
        <ref name="Flow.model"/>
      </element>
    </define>
    
    <define name="td.attlist">
      <ref name="Cell.attrib"/>
    </define>
    
    <define name="Cell.attrib">
      <ref name="Common.attrib"/>
      <optional>
        <attribute name="abbr">
          <ref name="Text.datatype"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="axis"/>
      </optional>
      <optional>
        <attribute name="headers">
          <ref name="IDREFS.datatype"/>
        </attribute>
      </optional>
      <ref name="scope.attrib"/>
      <optional>
        <attribute name="rowspan">
          <ref name="Number.datatype"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="colspan">
          <ref name="Number.datatype"/>
        </attribute>
      </optional>
      <ref name="CellHAlign.attrib"/>
      <ref name="CellVAlign.attrib"/>
    </define>
    
    <define name="CellHAlign.attrib">
      <optional>
        <attribute name="align">
          <choice>
    	<value>left</value>
    	<value>center</value>
    	<value>right</value>
          </choice>
        </attribute>
      </optional>
    </define>
    
    <define name="CellVAlign.attrib">
      <optional>
        <attribute name="valign">
          <choice>
    	<value>top</value>
    	<value>middle</value>
    	<value>bottom</value>
          </choice>
        </attribute>
      </optional>
    </define>
    
    <define name="scope.attrib">
      <optional>
        <attribute name="scope">
          <choice>
    	<value>row</value>
    	<value>col</value>
          </choice>
        </attribute>
      </optional>
    </define>
    
    <define name="Block.class" combine="choice">
      <ref name="table"/>
    </define>
    
    </grammar>
    I search one translator Italian/[2]/Englisch for my QT4 Projekt:
    http://sourceforge.net/projects/qt-webdav/
    http://sourceforge.net/projects/visual-xsltproc/
    http://sourceforge.net/projects/qtexcel-xslt/

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.