1

I have several XML styled documents and I have a XSD file that contains the documentation for some tags.

I want to link some of the docs out of the XSD to some elements in the XML.

The XSD documentation is for example: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/config.xsd?view=markup => element rtmphostlocal

Now I have an XML document for example here: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/src/base/mainAttributes.lzx?view=markup

There is an attribute:

<attribute name="rtmphostlocal" value="" type="string" />

I would like to link the XSD documentation from the element rtmphostlocal in the comment area of the other XML document. So that there is only a single source of docs to edit and I don't have to duplicate the comments everywhere I use the attribute. Kind of JavaDoc style.

How can I achieve that?
Is there some notation like in HTML with #anchors to link some element out of an XSD?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
seba.wagner
  • 3,800
  • 4
  • 28
  • 52
  • 1
    I am a bit confused. You have a XSD and a XML - but the content of the XML does NOT correspond to the XSD: the XSD defines an XML element `rtmphostlocal`, but in the XML you have an `attribute` element. How can you 'link' them if they don't even match? – MiMo Dec 11 '12 at 23:54
  • I'm even more confused than @MiMo – Tony Hopkinson Dec 11 '12 at 23:59
  • The only way I can see of doing this, would be to add an attribute to element confusingly called attribute in your xml with an XPath value to the "xsd". How you are going to get that into the xml I have no clue, because the link between one and the other is far from evident. – Tony Hopkinson Dec 12 '12 at 00:04
  • No that is just a special XML notation. I can later on use this "attribute" as a regular tag. In that sense I am extending the XML, so that I can write . However that is really not the issue. Maybe it is difficult to understand but basically I simply want to build a link or URL to directly reference a XSD documentation of an element. Same like you would do in JavaDoc when you reference a special variable or method. Something like mySchema.xsd#elementXYZ or some similar solution so that I can write a single source of documentation. – seba.wagner Dec 12 '12 at 00:39
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Dec 12 '12 at 02:51

1 Answers1

1

You want to be able to point from another document to the element declaration for rtmphostlocal in the schema document you show? It's an XML document; give the element declaration an ID, and point to it. The element declaration might look like this:

<xs:element name="rtmphostlocal" id="elem_rtmphostlocal">
  ...
</xs:element>

Some people might prefer to use xml:id="..." instead of id="...".

Whether the systems that read the link pointing into the document will be able to do anything useful with it depends mostly on whether they support XML fragment identifiers as specified in the XPointer spec. But you didn't ask for software that supports XPointer, you asked for a notation. Answer: yes, there's a notation. Use IDs.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
  • sorry I simply can't use that. Also I would like to link the documentation from arbitary points. I simply want to use a JavaDoc style reference note. It could be even another element where I want to write down => Look here for the documentation that is connected to this element. The reason for that is that this element is so central, but I don't want just duplicate the documentation that is actually written down in the XSD in every XML document. – seba.wagner Dec 12 '12 at 06:59
  • also the "id" attribute has in my XML already another meaning. The XML that I am using is "LZX", a XML, comparable to Flex MXML. And in this declaration "id" is already choosen to mean something else. – seba.wagner Dec 12 '12 at 07:01
  • but still thankful for your comment C.M. (although I guess some overdrive moderator will delete my comment in 5 minutes again). – seba.wagner Dec 12 '12 at 07:02
  • Sorry, I don't follow your logic. What is there about assigning an ID to the element you want to point at that prevents you from linking to it from arbitrary points? And what on earth can LZX have decided @id means, if not "this value uniquely identifies this XML element"? Good luck. – C. M. Sperberg-McQueen Dec 12 '12 at 16:45
  • Well this id has the meaning of unique identifier for the XML element. However you can't use it on all tags. Based on the LZX XML objects are created, and some of them are abstract. An – seba.wagner Dec 12 '12 at 21:37
  • Thanks for the clarification. If I had suggested you put an `id` attribute on the `attribute` element, your rationale would make sense. But I didn't. It's clear that we are not communicating successfully; good luck to you. – C. M. Sperberg-McQueen Dec 12 '12 at 21:43
  • sorry for that, I do understand now what you meant initially. However the issue is also that I just can't use this mechanism as not even the XSD will be defined in the schema definition of the LZX file. I simply want to reference some doc comment from my XSD in "any" XML document to have some nice cross links and save some time in maintaining the docs. Thanks anyway. – seba.wagner Dec 12 '12 at 22:55