Follow Slashdot stories on Twitter


Forgot your password?
Books Media Programming IT Technology

Embedding XML In Docs? 90

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."
This discussion has been archived. No new comments can be posted.

Embedding XML In Docs?

Comments Filter:
  • by beavis88 ( 25983 ) on Tuesday September 25, 2007 @01:55PM (#20746205)
    Keep including excerpts/relevant portions in the documentation, and separately, provide supporting reference materials - full XML files, XSD, etc.
    • Yes, I agree. Here are a couple of examples, one is from lecture notes for an XML class: [], the other is a book about OpenDocument Format: [], which includes lots of examples. Obviously, the same formatting and presentation could be used in a Word document.
    • Re: (Score:1, Interesting)

      by Anonymous Coward
      The SOAP/XML specifications in the WS-* family of specs use something people often call "pseudo-schema". Look at WS-Eventing [] for example. Section 2.1 describes this notational convention. And here is an example of how it is used to describe the "subscribe" SOAP message defined by the spec (section 3.1):

      <s:Envelope ...>
      <s:Header ...>
      <wsa:Action> []

    • 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.
      • Linky, linky, please???
        • 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 @02: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.
    • Right Tool: YAML (Score:3, Interesting)

      by goombah99 ( 560566 )
      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)

        by goombah99 ( 560566 )
        oops, Here's the link []. 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.
    • We then have automated processes which periodically pull certain pages, strip the navigation elements and render them to PDF

      The importance of keeping your distributed docs up to date, as described above, deserves emphasis. It's highly frustrating try to program to an API with an old version of the documentation.

      I also agree that Word is a lousy way to produce this type of documentation. I would go further and say that it is a poor tool to use for most non-static technical documentation. It's update
    • 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.'re just not hitting it hard enough.....
    • by cprael ( 215426 )
      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.
    • by Xiaran ( 836924 )
      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.
    • Wikis are the best tool to do this, but it should be a wiki that supports XML coloring and attachments like Deki Wiki. Check out this sample page [] AND, it's free open source! []
  • We're stuck with Word
    Word file is the worst way to document xml ever. Try a hyperlinked help file or plain html, much easier to do something neat.
  • <XML documentation>
    XML documentation
    </XML documentation>
    i keed, i keed
    • by dvice_null ( 981029 ) on Tuesday September 25, 2007 @05: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)>
      <![CDATA[<XML documentation>XML documentation</XML documentation>]]>
  • by mrjb ( 547783 ) on Tuesday September 25, 2007 @02: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:

              ping - send ICMP ECHO_REQUEST packets to network hosts

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

              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

    PING ( 56(84) bytes of data.
    64 bytes from ( icmp_seq=1 ttl=245 time=11.3 ms
    64 bytes from ( 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:

        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:

          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.
    • by jhol13 ( 1087781 )
      Completely off topic, but see [].

      This is why I use Sun manual pages (even though they miss GNU extensions and are sometimes very slow).
  • 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.
  • I really don't know if this is a good idea
  • JSON (Score:4, Interesting)

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

    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 texwtf ( 558874 )
      ..well, it's good for message passing anyway. It may not be what you want for embedding documentation. Sorry for the late clarification.
  • by mdm-adph ( 1030332 ) on Tuesday September 25, 2007 @02:11PM (#20746403)
    ...XML document itself. :P

    (Isn't that the beauty of it?)
    • by Tackhead ( 54550 )
      > 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>

      • Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.

        Not everything is instantly understandable.

        For help on the sentence, see wikipedia [].
      • 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.
        • by dossen ( 306388 )
          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 @02:14PM (#20746417)
    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)

      by beavis88 ( 25983 )
      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...
      • This may help you out

        It started as a simplified subset of the Standard Generalized Markup Language (SGML), and is designed to be relatively human-legible. []
        • Which doesn't contradict the GP. XML is an easy to parse and validate fragment of SGML. It is also slightly easier for a human to read.

          Indeed, I just rephrased your quotation.
          • by thogard ( 43403 )
            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.
            • And both take an infinite amount of money.
            • If its so easy to parse, why are the libraries that parse it such a pain to use?

              Probably because, as someone else pointed out already, XMl is intended to express structured data. Therefore, it's best to have some idea what the structure is before you start parsing it. Sure, you can just grab a stream and start pulling tags out of it, but then you have to keep track of what tag you're working with, make sure things are well-formed and a bunch of other stuff that gets in the way of just grabbing the data you went in for in the first place.

              OTOH, if you've got the schema for the XMl you

          • XML is an easy to parse and validate fragment of SGML

            XML and SGML are not interchangeable. <foo/> is a self-closing tag in XML. <foo/ is a self-closing tag in SGML (full SGML really has weird syntax to anyone used to HTML or XML). XML is easier to parse than SGML, specifically because it is not SGML.

    • by iabervon ( 1971 )
      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 [] 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

  • by Reality Master 101 ( 179095 ) <RealityMaster101 AT gmail DOT com> on Tuesday September 25, 2007 @02:23PM (#20746521) Homepage Journal

    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 [] or [] 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 []
  • Using a less difficult markup... JSON [].
  • by Cheefachi ( 970662 ) on Tuesday September 25, 2007 @03: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 @03: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.
    • Use Word styles (Score:2, Informative)

      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.

  • Well obviously you should provide schemas as well, so basically the question is how to do you make sure that the document and the schema are kept in sync, yes?

    So it seems that it's a publishing cycle question. You should have a source document with placeholders that some later process replaces with code snippets. Your schemas could have foreign nodes that denote placeholder Ids, for to map them up.

    You could use Docvert [] which lets you make XML Pipelines from content and build plugins and conversion stage

  • The only way to win is not to play.
  • Use XML (Score:3, Informative)

    by frisket ( 149522 ) <peter@[ ] ['sil' in gap]> on Tuesday September 25, 2007 @07: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 [] 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.

    • by zbend ( 827907 )
      Wait a minute you have people writting documentation for xml schema that don't understand XML? Sounds like the XML schemas I have to consume. You don't work for the state of MN do you?
    • by nagora ( 177841 )
      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

    • by cprael ( 215426 )
      "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

      • Now read the rest of what I posted.

        • "Now read the rest of what I posted."

          You are confused in thinking that my post was for your benefit. It's great that you've " ...played some with Open Office, but it isn't there yet." When you've worked with OpenOffice, and it was on the same day you posted, your opinion may have some validity. What you meant to say was "I've played with OO, but it wasn't there yet at the time." You are a professional writer and you can't match tense in a sentence? You've probably been relying on Words flawed grammar c

          • The latest of those times was three weeks ago. Is there a new release I don't know about?

            I'd like OO to do what I need it to do as well as MS Office does; I'm about to add a system and it would be nice to save the high cost of buying a whole new suite from Microsoft. Of course, I'd still have to buy Visio.

  • 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
  • Create an specific parragraph style (i.e. XML code) for the XML bits you want to put in your document. In terms of borders and background, make it as complicated or minimallistic as you wish, but I strongly suggest using courier new our any other monospace font.

    You may also find useful to tag every document with a caption, so you can reference it later on (and do things such as "see the example on page xxx", with xxx being a reference).

  • I hate Word, but I use it for specifications that need to be available off-line because it provides the best printable-output of the various source-formats my organization allows.

    My technique is still evolving, but I currently specify an XML format by first describing its purpose/context in plain-text, followed by a UML class diagram to visualize the information it captures, followed by an XML example, followed by its XSD. For the class-diagram, I use WSD so it will print well and I scale it so that it f
  • by srussell ( 39342 ) on Wednesday September 26, 2007 @07:43AM (#20753759) Homepage Journal
    If you're using XMLSchema, then ditch that crap and use RelaxNG [], which is actually readable. There's a compact syntax [] that is even more user-friendly. As an example, the schema for:

    <name>John Smith</name>
    <name>Fred Bloggs</name>
    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.
  • My company makes software that uses XML messages as the interface between a user's invoicing system and our system for tax calculation. The schema for the various messages is well-commented, but we felt the raw XML wasn't as human-friendly as we'd like.

    We tried output from XML Spy which was an improvement for some purposes, but what we really wanted was a succinct table that listed each element/attribute along with its occurance info, valid values, and a text description. We initially did this manually in E
  • 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
  • This Works For Me (Score:2, Informative)

    by ToxicBanjo ( 905105 )

    Like most coders I've been having to do this for some time. My approach seems to allow our customers to easily understand the XML we use:

    1. Data Requirements (DB Schema and Expected Values/Ranges)
    2. Sample XML Without Data, Just the Schema Values From (1). ie. [FirstName]nVarChar(15)[/FirstName]
    3. Then Show the XSD File That Validates the XML.

    Then a full description of each element, etc followed by some samples. True this can get lengthy for really complex schemas but even then it makes it pretty

Today is a good day for information-gathering. Read someone else's mail file.