Pages: 1
Print
Author Topic: Handling ID references in Xmetal  (Read 2673 times)
krish7
Member

Posts: 13


« on: September 15, 2009, 11:11:22 PM »

Hello all

I have an issue in validating the IDREFs in my XML file using XMetaL.
I see in the user guide description that
"The value of an IDREF attribute must be the value of an ID attribute somewhere in the
document
.When the document is validated, XMetaL Author checks that the corresponding ID attribute exists in the document."

But I am not sure what/where this other ID attribute would exist and how it is linked to this IDREF.

Can anyone explain this scenario to me?

Thanks in advance.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #1 on: September 16, 2009, 11:25:40 AM »

The mere existence of an ID attribute with a matching value is enough to allow the document to validate. The value must be an exact match.

XMetaL (Author and XMAX) is fulfilling the following requirement during validation in this case:
http://www.w3.org/TR/REC-xml/#idref

Whether your customization chooses to put any relevance on this "linkage" is up to the maker of the customization and will also be very much dictated (or at least guided) by the maker of the DTD or Schema and their intentions for the ID and IDREF (which also leads to questions about the intended usage of the XML if it is to be transformed to another format at some point).

I have seen customizations created by clients that list all the ID values and IDREFs next to each other in a table inside a modal form (presumably to allow the author to more easily work with them) and I have seen customizations where clicking on the element containing an IDREF will take you to its match, and vice versa (though in the case of an ID there may be more than one IDREF). You may wish to implement something elaborate that lets someone choose (from a list in a form for example) from a list of ID values when inserting an element containing an IDREF.

Any additional functionality such as this, if required, would be primarily done via scripting using the APIs provided for these purposes (see: XMetaL Developer Programmers Guide).
Logged
krish7
Member

Posts: 13


« Reply #2 on: September 22, 2009, 01:08:37 AM »

Hi Derek

Thanks for the response.

Please find the sample file attached for the issue.
In the actual scenario, for some cases, the id values are present in the same file for an idref, but some others are missing.
Is there a way via scripting to avoid the error message?
Please provide me some details on this.

Thanks in advance.

* internal reference.zip (0.48 KB - downloaded 144 times.)
Logged
krish7
Member

Posts: 13


« Reply #3 on: September 22, 2009, 01:26:03 AM »


I am looking for something which can be done based on the below article or something similar.
"http://forums.xmetal.com/index.php/topic,319.0.html"

Can you guide me whether this is the right approach ?

Thanks again.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #4 on: September 25, 2009, 03:41:47 PM »

I'm not sure what you are asking for exactly.

1. How to suppress the validation error in this case (ie: leave the document invalid but don't bug the user about it).
2. How to automatically hunt through a document for elements with missing id attribute values and somehow guess what those values should be set to.
3. Show a list of elements with idref attributes that do not have corresponding id values and help the user populate an id value on an element that would correspond. This might be implemented various ways (the part where the user is prompted for information anyway).
4. Something else entirely.

If you could describe what the behavior you need is someone might be able to help out.
Logged
krish7
Member

Posts: 13


« Reply #5 on: September 30, 2009, 12:07:07 AM »

Hi Derek

I am looking for something as you described in case 1 and 2. I would be interested in implementing either of these.

Any suggestions in this direction would be of great help.

Thanks again.
Logged
eom4work
Member

Posts: 1


« Reply #6 on: March 15, 2011, 09:50:17 AM »

Is there a way via scripting to avoid the error message?
Please provide me some details on this.
Is there a way via scripting to avoid the error message?
Please provide me some details on this.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1548



WWW
« Reply #7 on: March 16, 2011, 05:45:57 PM »

There is no way to suppress individual validation errors while leaving the document in an invalid state so you cannot do both 1 and 2. If you wish to have option 1 then I think you will need to turn validation off entirely. See the following posting: http://forums.xmetal.com/index.php/topic,1120.0.html

The only other thing I can think of would be to modify the DTD so that the IDREF is not a true IDREF, but perhaps CDATA. In this case XMetaL will not enforce the XML IDREF rules for the attribute. Perhaps this is desireable if you wish to rely on some other system to match the two attributes? You haven't provided enough information to know that is the case, but I get the feeling you might have other systems involved here.

For option 2 do you want to completely automate this inside XMetaL Author? The user would not be involved at all? If that is the case you must be able to imagine a system that can automatically decide which ID values to match with IDREF values all by itself. I cannot imagine such a system myself, but perhaps you can. As long as specific logic can be defined then you should be able to write a script to implement it.

If the user needs to be involved to provide feedback on which ID and IDREF to match up then we probably need to think about some kind of user interface. If you can describe what that might look like I can probably make some further suggestions. However, at its simplest you would likely need to obtain a list of all IDREF values that do not have a matching ID value and display those to the user in some fashion. The user could then select either the ID or the IDREF and subsequently select its match. If some external source also needs to be involved (perhaps a database lookup or something else) then you would need to hook into that as well.

You can find a simple example that matches two elements using their attribute values in the Journalist demo:

1. Create a new Journalist document.
2. Open the "Journalist 2" toolbar.
3. Click on the "red book" icon to "Insert BiblioItem".
4. Inside the <Designator> element type some text.
5. Place your cursor inside a <Para> element.
6. Click on the "open book" icon to "Insert Citation". You will see a dialog that lists all the <BiblioItem> elements and lets you choose between them based on the text inside each of their <Designator> elements. The actual linking that is done is based on attributes. It is this last dialog and the associated code that I am suggesting you might use for inspiration.
« Last Edit: March 16, 2011, 05:56:16 PM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us