0

how would one go about parsing a dtd-file with JS? e.g. converting it to an object for further manipulation. the overall goal is to parse a DTD and visualize it via javascript into a tree structure like this in the browser (e.g. Chrome)

simple DTD for demo purposes (books.dtd)

<!ELEMENT books (book)*>
<!ELEMENT book (front,page,back)>
<!ELEMENT front (#PCDATA)>
<!ELEMENT page (#PCDATA)>
<!ELEMENT back (#PCDATA)>
<!ATTLIST book
   isbn     ID    #REQUIRED
   title    CDATA #REQUIRED
   author   CDATA #REQUIRED
>

books.dtd / source: Treevision Ovidius

(source: books.dtd loaded in Treevision Ovidius)

hints in the right direction are much appreciated! I can't find anything or I'm just searching for the wrong things

update: a friend hinted, that another possibility could be to transform the DTD via XSLT to JSON and use the resulting file

DTR9000
  • 159
  • 2
  • 11
  • 2
    https://www.npmjs.com/package/dtd-diagram – Justinas Mar 06 '18 at 14:44
  • thank you for pointing me to this! I think I can extract suitable parts from this and [npmjs.com/package/dtdanalyzer](https://www.npmjs.com/package/dtdanalyzer) – DTR9000 Mar 06 '18 at 15:16

0 Answers0