Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Embedding XML In Docs?

Posted by kdawson on Tue Sep 25, 2007 12:53 PM
from the techniques-and-tips dept.
An anonymous reader writes "Now that XML is the de facto standard (for good or ill) for doing message passing, I find that I need to give XML examples in the documentation that we produce. We're stuck with Word and up till now I've just been doing the examples as cut and paste from the log files. We include schemas in the appendix but it seems that the clients like the 'readability' of the raw XML over other approaches we've tried. I'm wondering what everyone else is doing in the world of XML documentation."
+ -
story

Related Stories

Submission: Embedding XML in docs by Anonymous Coward
This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • by beavis88 (25983) on Tuesday September 25 2007, @12:55PM (#20746205)
    Keep including excerpts/relevant portions in the documentation, and separately, provide supporting reference materials - full XML files, XSD, etc.
    • We use a large XSLT file (more accurately a series of files with xsl:includes) which document the functions of the XML. You can transform any XML query or response with this XSL, and it will document the call for you. There's also an XML file which when transformed with this XSL will give you full schema documentation.

      So it's your choice, you have complete documentation, or you can get documentation on any call by passing its content through the XSLT.
        • Sorry, it's for internal applications shared between teams, I don't have a public link to it.

          It's basically a series of <xsl:template match="functionname"> or <xsl:template match="functionname[conditional='foo']">, with markup to describe the purpose, arguments, etc of the functions. The "all documentation" XML file is a table of contents and series of dummy calls or responses which the individual documenting xsl:templates then mark up.
  • by Anonymous Coward on Tuesday September 25 2007, @01:00PM (#20746271)
    Asking how to do this in Word is like asking how to cut a board in half with a hammer. In both cases, you're using the wrong tool for the job.

    That said, I can tell you what we do for documentation. We have a wiki (Confluence, though any should work) that is perfectly capable of handling XML or any of a number of languages. We then have automated processes which periodically pull certain pages, strip the navigation elements and render them to PDF which, depending on the process, get transfered to various locations (samba fileshare, a couple of different intranet sites we maintain or into our CMS workflow to be approved and added to our public site).

    Since it's a wiki, the input is easy and anyone in our company can contribute (if we were larger, we might add more access controls). Yet it also produces professional-looking PDF documents.
    • If I understand the question right, how to present structured documents within human readable text then closest you will ever come to a right answer is YAML. look it up at wiki pedia.
      • link (Score:3, Interesting)

        oops, Here's the link [wikipedia.org]. Also a word of advice: you can embed XML without modification in YAML just by indenting it. So you can have both in the same document. Unlike XML, YAML allows for some (limited) relational hierarchy and for type casting as part of the language itself. You can use this to simplify a highly nested XML document with lots of redundant entries. just make an !!xml type-def.
    • Asking how to do this in Word is like asking how to cut a board in half with a hammer. In both cases, you're using the wrong tool for the job.
      No...you're just not hitting it hard enough.....
    • One works with the tools one has available. The startup I'm writing docs for right now works in Word (Office 03, actually). The previous one used Frame, because they actually had _had_ a full-time writer before I came on board.

      Word is perfectly capable of accepting XML input. 2 of the 8 docs I've been working on this month have XML in them. It works out just fine.
    • While I agree with you 100% I must say Ive been in business environments where they *insist* that it be word format. No PDF. No HTML. And if you get caught using something like *gasp* open office you get reprimanded. Sad but true.
  • by mrjb (547783) on Tuesday September 25 2007, @01:05PM (#20746327)
    No trolling intended, but just having the schemas is like just having the UNIX man pages without examples.

    Let me clarify, bear with me- The man page for 'ping', for instance, is all-encompassing but rather intimidating when it comes to every-day use:

    NAME
              ping - send ICMP ECHO_REQUEST packets to network hosts

    SYNOPSIS
              ping [-dfnqrvR] [-c count] [-i wait] [-l preload] [-p pattern]
                        [-s packetsize]

    DESCRIPTION
              Ping uses the ICM... etc

    Okay, enough. At that point, they've more than lost me. All I want to know is, How do I use it?
    A simple example gives much more 'instant gratification' style information:

    user@host:~$ ping www.google.com

    PING www.l.google.com (64.233.183.104) 56(84) bytes of data.
    64 bytes from nf-in-f104.google.com (64.233.183.104): icmp_seq=1 ttl=245 time=11.3 ms
    64 bytes from nf-in-f104.google.com (64.233.183.104): icmp_seq=2 ttl=245 time=69.3 ms ...

    This is enough for everyday use. No need to bother with the gritty details at first. Once the users get to that point, they won't mind the schemas and full help descriptions.

    • Let me clarify, bear with me- The man page for 'ping', for instance, is all-encompassing but rather intimidating when it comes to every-day use:

      Perhaps, but it bears repeating that in most cases, man pages can be considered both authoritative and complete. Compare that with what you typically get with commerical vendor-supplied documentation. I'll agree that for casual use, reading a manpage can be overwhelming, but so is reading a manual of any sort. The more features there are, the more there is to rea
      • As for your ping example, I don't know what version you're using, but typically the manpage would take the form of:

        ping [option] [option] [option] [option] host

        Mine's even worse than the grandparent's:

        SYNOPSIS
        ping [-AaDdfnoQqRrv] [-c count] [-i wait] [-l preload] [-M mask | time]
        [-m ttl] [-P policy] [-p pattern] [-S src_addr] [-s packetsize]
        [-t timeout] [-z tos] host
        ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]

        • From Debian:

          SYNOPSIS
          ping [-LRUbdfnqrvVaAB] [-c count] [-i interval] [-l preload] [-p pattern]
          [-s packetsize] [-t ttl] [-w deadline] [-F flowlabel] [-I interface] [-M hint]
          [-Q tos] [-S sndbuf] [-T timestamp option] [-W timeout] [hop ...] destination

          The granparent should be pleased, his manpage is actually the most readable.
  • We include schemas in the appendix but it seems that the clients like the 'readability' of the raw XML over other approaches we've tried. I'm wondering what everyone else is doing in the world of XML documentation.
    Having as little to do with it as possible. Everybody just grabs any raw XML they can find in order to try and understand it, and they fly by the seat of their pants. Not much you can say will change that.
  • JSON (Score:4, Interesting)

    by texwtf (558874) on Tuesday September 25 2007, @01:11PM (#20746397)
    Before you flog yourself too much with XML, check out JSON: http://www.json.org/ [json.org].

    It's supported by every language under the sun, and really simple to use. You may end up needing the extra capabilities of XML, but if you don't JSON is a much friendlier experience.
  • by mdm-adph (1030332) <<mdmadph> <at> <gmail.com>> on Tuesday September 25 2007, @01:11PM (#20746403) Homepage
    ...XML document itself. :P

    (Isn't that the beauty of it?)
    • > I always let... ...XML document itself. :P
      >
      > (Isn't that the beauty of it?)

      <SENTENCE>Because if <SUBJECT>it</SUBJECT> <PREDICATE>was impossible</PREDICATE> for a <OBJECT>human</OBJECT> to generate, <SUBJECT>it</SUBJECT> <PREDICATE>should be impossible</PREDICATE> for a <OBJECT>human</OBJECT> to understand!</SENTENCE>

      • You remind me of the cardinal tenet of XML:

        XML is like violence. If it's not solving your problem, you're not using enough of it.
        • Or as one of my coworkers just said: "XML is like alcohol, use enough and you can't see the problem".
    • If you choose the tagnames wisely, this can be true.

      Unfortunately, I suffer from a colleage who favours single letter tag and attribute names :-(

      Oh, and I use Natural Docs to create documentation and use (start code) ... (end code) to document the XML within inches of the place where the XML is generated or parsed.
  • Documenting XML? (Score:3, Interesting)

    by DogDude (805747) on Tuesday September 25 2007, @01:14PM (#20746417) Homepage
    I thought that the point of XML was to embed the documentation in with the data, so that it was human-readable? This doesn't make any sense. If XML has to be documented anyway, then what's the point? To increase network traffic? To fill up "extra" hard drive space? Old fashioned character-delimited is a better way to go if you have to document the thing, anyway.
    • Re: (Score:3, Informative)

      I thought that the point of XML was to embed the documentation in with the data, so that it was human-readable?

      This is definitely not the point of XML. The point is generic exchange of structured data, with the ability to validate and query the data.

      You could certainly argue it hasn't lived up to those aims, but that's a different argument in my book...
          • If its so easy to parse, why are the libraries that parse it such a pain to use? Also why do they burn memory like crazy as well?
            Knuth has written a few things about why this style of parsing is bad (he used it in TeX) and why it should be avoided for anything but interactive stuff. If you do the proofs, you will see that XML errors diverge to two states, one takes an infinite amount of time and the other an infinite amount of memory.
    • It's so that intermediary software can manipulate the files without knowing anything about the semantics. For example, jabber makes good use of it so that clients can support a variety of extensions while services only need to handle a single function while letting messages with additional contents pass through intact.
  • If you need to have XML fragments in your Word document, one of your best options is to copy and paste from Visual Studio. The result is nicely indented, colorized and mono typed. If you don't have Visual Studio, you can download it Visual Studio Express [microsoft.com] for free.

    Just open Visual Studio and create a new XML file (don't create a project-- there's no need to do so; just use File->New->File... and select XML file). Copy and paste your XML fragment into the new file. Press Ctrl-K, Ctrl-D to reformat

  • You do good XML documentation the way you do good documentation of any kind...

    1) Examples.

    2) Functional examples.

    3) More examples.

    People learn best when they have a skeleton of knowledge to hang the meaty details on. By all means, have a detailed description of each element in the XML, but give lots of examples so people can get a sense of the big picture of what's going on. And make sure your example are real-world enough to cut/paste and modify for people who need to get something up and running in a hurry.

    There's a reason that K&R is considered one of the best language books every written. It has tons of examples, and also has a lot of the formal stuff in a useful format.

  • And XSD with a good XML editor is better than most documentation you could produce.

    Throw comments into the XSD, and it's gold.
    • Imagine the ODF spec within comments of the schema... or the OOXML one, if you are into S&M.
      • ODF spec within comments of the schema...S&M

        Right. And what about capturing mechanisms? For example if you had to take the value from one part of the XML...

        for $x in doc("books.xml")/bookstore/book
        where $x/price>30
        return $x/title

        ...and put it in another such as adding it to /bookstore/premium/collection/booksover30/title

        That's where notation systems such as http://www.bpmn.org/ [bpmn.org] or http://www.oasis-open.org/committees/wsbpel [oasis-open.org] might be useful.

  • If you're already dealing with XML files, I would suggest that the main barrier to using a toolset such as DocBook (SGML or XML variants) should be gone already.

    DocBook is excellent at enforcing proper structure and contains all the elements you need (really!) to write tech documentation.

    Several high profile projects such as FreeBSD, KDE, GNOME and others use DocBook as their main doc format, as do I believe more tech companies than actually want to admit it. I maintain the PF tutorial at http://home.nuug.n [home.nuug.no]
  • by Cheefachi (970662) on Tuesday September 25 2007, @02:05PM (#20747057)
    We publish tons of documentation that has to explain XML formats. What we do is include DTD diagrams in our documentation that shows the structure of the XML document graphically. The tool we use to generate them is Tibco's TurboXML and we've been using it for years. Obviously we include examples, but the DTD diagrams really show you all you need to know. I know, I know its commercial software. Maybe there's something open source out there that does something similar, not sure. Hope this helps!
  • by Mortanius (225192) on Tuesday September 25 2007, @02:49PM (#20747617) Homepage
    For those of us actually interested in opinions / answers to the poster's question, please actually respond to the QUESTION. Anonymous didn't ask for criticism over the choice of languages, keep that in mind.
    • This is what I did. Create a new style based on predefined style HTML Preformatted. Name it XML Sample. Make sure "Style for following paragraph" is also XML Sample. I use a 15% Gray background pattern and Courier New 10pt and a 0.3" indent to set it off.

      For better or worse, where I work, tech specs are Word. I use the style just mentioned for my XML or sometimes embed XML Spy schema fragments as JPEG.

  • Use XML (Score:3, Informative)

    by frisket (149522) <(peter) (at) (silmaril.ie)> on Tuesday September 25 2007, @06:52PM (#20750347) Homepage

    If you're serious about doing documentation, use an XML editor with something like the DocBook DTD/Schema, not Word. Word is for shopping lists and letters, not "real" documentation. And yes, Word does actually have a real XML editor, but it's pretty crummy; and no, Save As XML (WordML or OOXML) doesn't count.

    The problem is that most XML document editors suck for non-XML-gurus. They can display either plaintext with syntax colorisation (Emacs/psgml/xxml) or pseudo-WYSIWYG, but lack the interface smarts that would make them usable (see my paper to Markup last year [epu.ucc.ie] on this topic, or wait for the full report next year :-). Both have their advantages and disadvantages but they all require a fairly deep prior knowledge of XML. In your own case this may be fine, but not if you want to hand the editing suite to your non-XML colleagues.

    A good documentation system takes some effort to build, but the results in terms of usability, persistence, quality, etc are usually well worth it. In the specific case of quoting code, XML's CDATA section feature lets you embed code verbatim, and one of the possible outputs is to transform the XML to LaTeX using XSLT, and thus enable the use of things like the listings package, which makes pretty-printed code in your PDFs.

    • If you're serious about doing documentation, use an XML editor wi

      Sorry, just had to stop you there. If you're serious about doing anything - don't touch XML. It's shit, it was designed by idiots and it achieves nothing. Just don't go there. Use TeX or Word or a fucking crayon.

      The reason XML editors suck is that XML is hopeless for human editing. It is too complex, to losely defined (ie, it's TOO general) and even reading it is a pain, let alone writing it.

      Stamp out XML at every opportunity; like cockroch

    • "If you're serious about doing documentation, use an XML editor with something like the DocBook DTD/Schema, not Word. Word is for shopping lists and letters, not "real" documentation."

      I have to ask. How many years have you made a living writing "real" documentation? Because I really, seriously get the impression that your idea of doc is "commenting my code for college credit".
  • Pay no attention to the neanderthalers who want you to regress to some text processing application.

    Word is ideal for tech documentation, as it gives you the tools to do better-than-good typography, as well as to easily enhance the text with illustrations and inclusions—to create documentation that's tuned for the reader, not the writer.

    I'm assuming you know how to set up suitable styles. For the rest, you have more than cut and paste as an option. Keep in mind that you can embed just about any file

    • "Word is ideal for tech documentation, as it gives you the tools to do better-than-good typography, as well as to easily enhance the text with illustrations and inclusions--to create documentation that's tuned for the reader, not the writer."

      1997 called and wants it's analysis of Word back. In '97 Word was the best solution. I wrote professional level technical documentation for distribution to clients using Word 97, and it is was best of breed. Flash forward to 2007. There is a tool called Open Office

  • Its designed for doing technical documentation. It began as a SGML toolset but has since moved on to XML.
  • I wrote an XML book a decade ago and I don't understand how it is different than documenting any other programming technology. You write chapters on various topics and you cut and paste examples into appropriate places with appropriate prose around them. Word, FrameMaker, TeX, DocBook, DITA: the container documentation technology is not particularly relevant. I mean sure, there are more sophisticated things you can do (auto-testing, auto doc-generation, XML escaped within XML etc.) but you need to tell us w
  • Well, the XML docs I'm in the middle of writing currently have XML snippets embedded in the doc, and pointers to XSDs and suchlike as appropriate. The version of the doc that's going to come down the pike in about 6 months will have pointers to the schemas, cross-links to "live" XML sample code (plus the raw text thereof incorporated as appendices), etc. But that's waiting on the dev-rel server to go live. Lack of a reliable hosting space can be so... problematic.

    As for tools - one works with what one has/c
  • by srussell (39342) on Wednesday September 26 2007, @06:43AM (#20753759) Homepage Journal
    If you're using XMLSchema, then ditch that crap and use RelaxNG [relaxng.org], which is actually readable. There's a compact syntax [relaxng.org] that is even more user-friendly. As an example, the schema for:

    <addressBook>
    <card>
    <name>John Smith</name>
    <email>js@example.com</email>
    </card>
    <card>
    <name>Fred Bloggs</name>
    <email>fb@example.net</email>
    </card>
    </addressBook>
    looks like this:

    element addressBook {
    element card {
    element name { text },
    element email { text }
    }*
    }
    Use your imagination to pretend that /. preserves indentation. --- SER
  • We use XML a lot to pass business objects around. Often through web services (SOAP), but not only. We never document the XML structure itself (although there is some documentation in our WSDL files). Instead we describe the business objects. Each object has a name and a list of fields. The field has a type (primitive or Object type), a length, a multiplicity (1, 0..1, 1..n, 0..n usually) and a description. All the semantics go into the description. The meaning of some fields may depend on the performed oper
    • This is exactly how the workforce management application I work with passes its transactions. When I started the job, I knew nothing about the backend of the app, since I had only used it in the field, and thus seen the frontend. By the end of the day, I was reading log files and XML transactions as they flowed. I was able to understand the data and the schema immediately because it contains intelligently crafted tagnames and structure. Maybe not all XML is like this, but the gobbledygook I see each day is
  • find a text editor that can color you xml, I use Programmers Notepad but there are many that will do the job.
    Export the xml file to html and then copy/paste from ie to word. "xml now in real color!"
    but you just do that in the overview documents, you also need to provide a real reference and not just a DTD you need to provide detailed appendix style document in human readable form.
  • I recommend two things:

    XML Sample files
    Store sample documents in a \Samples subdirectory under the directory storing the word files. The word document must 'include' them by using the "Insert\File\Insert as Link" functionality in MS word.

    XML Structure tables
    The most useful way to illustrate XML visually doing the following:
    1. Take an XML document that illustrates as much of the schema as possible.
    For instance, this could be a document that includes all optional elements. (This may not be possible in some ca
    • by dvice_null (981029) on Tuesday September 25 2007, @04:38PM (#20749053)
      That is pretty good, but as your example is not valid XML, we need to wrap it inside a valid XML to make it actually work:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE documentation [
      <!ELEMENT documentation (#PCDATA)>
      ]>
      <documentation>
      <![CDATA[<XML documentation>XML documentation</XML documentation>]]>
      </documentation>