Skip to main content
4everJang
Legend
January 19, 2012
Answered

Preserving cross-references to/from XML

  • January 19, 2012
  • 1 reply
  • 2406 views

Hello all,

I am roundtripping from stuctured Frame to XML and cannot figure out how to make FM restore my cross-reference targets.

My edd shows the <xref> element as this:

Element (CrossReference): xref

     Attribute List

          1.     Name: XrefTarget     IDReference     Optional

The DTD was generated by Frame from the EDD, and shows the following definition for <xref>:

<!ELEMENT    xref       EMPTY >
<!ATTLIST     xref       XrefTarget  IDREF     #IMPLIED
                     format    CDATA     #IMPLIED
                     srcfile    CDATA   #IMPLIED >

The read/write rules should not be required, but after it did not work without a specific rule, I included this one:

element "xref" {

          is fm cross-reference element;

          attribute "XrefTarget" is fm property cross-reference id;

          attribute "format" is fm property cross-reference format;

}

The XML output (with or without the read/write rules, that does not seem to make a difference) show this:

<xref format = "NumberRef"
    srcfile = "../RepGeneral.fm#t-replace-reagent-rotor"/>

The @srcfile is generated by Frame. What is worrying is that @XrefTarget is not set here. And indeed, when I read the XML back into Frame, <xref> shows up with the correct format but no content in its @XrefTarget. I tried everything and I am getting just a little annoyed with Frame's supposedly intelligent default behavior. I do NOT want to get into API programming, I just want Frame to do what it claims to do by default. If I need to make changes to the EDD or read/write rules, I will, but I am not finding useful information on what exactly is expected here.

Anyone ?

Thanks a lot in advance

Jang

This topic has been closed for replies.
Correct answer 4everJang

Seems like I am the only one doing this ???

Anyway, I was trying all kinds of stuff and stumbled upon the solution: the XrefTarget attribute in the DTD, which is supposed to be of type IDREF is ignored completely by Frame. Instead, the combined value of the source file and ID to which the cross-reference points is written into the srcfile attribute. And the funny thing is: when I change the XrefTarget attribute to CDATA, all of a sudden it is used for the reference instead of the srcfile attribute. I don't see this reflected in the documentation anywhere, but it works, so I am happy with that.

Ciao again.

Jang

1 reply

4everJang
4everJangAuthorCorrect answer
Legend
January 19, 2012

Seems like I am the only one doing this ???

Anyway, I was trying all kinds of stuff and stumbled upon the solution: the XrefTarget attribute in the DTD, which is supposed to be of type IDREF is ignored completely by Frame. Instead, the combined value of the source file and ID to which the cross-reference points is written into the srcfile attribute. And the funny thing is: when I change the XrefTarget attribute to CDATA, all of a sudden it is used for the reference instead of the srcfile attribute. I don't see this reflected in the documentation anywhere, but it works, so I am happy with that.

Ciao again.

Jang

josephb44551697
Known Participant
June 28, 2019

Jang,

I know it has been years since the last post, but I wondered if you had any additional guidance regarding this issue. I am having seemingly the same issue as you, but haven't found a solution yet. I tried doing what you said above, but did not have any success. Is there anything else that you found helped maintain cross-refs in the FrameMaker XML roundtrip? I am using FM 2019.

Thank you,

Joseph

Inspiring
June 28, 2019

Joseph,

   A cross-reference is a link from one spot in a document to a spot in the same or a different document. FrameMaker calls the target of this link its "source" because the target is the source of information (such as a title, autonumber, or page number) displayed by the cross-reference. FrameMaker supports two types of cross-references, which I describe as element based and marker based. The source of an element-based cross-reference is an element that has a unique ID attribute. Internally, FM uses the value of the ID attribute to find the source elements.   I The source of a paragraph-based cross-reference is a cross-reference marker.

   When you create a cross-reference in structured FM, you select the Source Type from a pop-up menu that gives four choices:

     Paragraphs

     Cross-Reference Markers

     Elements Listed in Order

     Elements Sorted by ID

   When you choose either Paragraphs or Cross-Reference Markers, make appropriate selections, and click Insert, FM creates a marker-based cross-reference. If you chose Paragraphs and select a paragraph that already contains a cross-reference marker, FM uses the existing marker as the source. If the paragraph does not contain such a marker, FM creates one.

   The difference between the two Elements options is the order in which elements that have unique ID attributes are listed, and whether the value of their unique ID attributes appear in the dialog box. Internally, FM stores the unique ID of the source element in its data structure for the cross-reference element and uses this ID to find the source element when it updates cross-references. If the cross-reference element's definition include an ID Reference attribute, FM also stores this value in the cross-reffereence's first ID Reference attribute. You can insert a cross-reference whose source is an element whose ID attribute is not yet set, and FrameMaker will assign a value to that attribute.

  You can create both element-based and marker-based cross-references in both structured and unstructured documents. However, you have to be using the Structured FrameMaker product interface to see the element-based Source Types. Of course, to create an element-based cross-reference, the source must be within a structured document or flow.

  You can ensure that only element-based markers are used in valid structured document by making their ID Reference attributes required. FM will still let you create a marker-based cross-reference but it won't be valid because the ID Reference attribute won't be set.

   When it reads or writes XML, FM exports element-based cross-references using the XML's IDREF attribute to the ID value of the FM source element's unique ID. As Jang's old message relates, a r/w rule is needed to name this IDREF attribute if the element tag differs from FM's default. For many releases, FM simply converted marker-based cross-references to text because there is no way to identify the source with an ID reference attribute. Later releases export marker-based cross-references as elements but use a srcfile attribute (whose value contains the filename containing the cited marker as well as the marker text) instead of an IDREF attribute for such cross-references.

  If you are seeing srcfile attributes in your XML where you want IDREFs, the FM cross-references will need to be changed to define the link with attributes. If your cross-references are element-based but generated XML does not include the value of IDREF attributes, add a r/w rule of the form Jang gave above.

   --Lynne