Highlighted

Preserving cross-references to/from XML

Advocate ,
Jan 19, 2012

Copy link to clipboard

Copied

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

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

TOPICS
Structured

Views

1.3K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Preserving cross-references to/from XML

Advocate ,
Jan 19, 2012

Copy link to clipboard

Copied

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

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

TOPICS
Structured

Views

1.3K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 19, 2012 0
Advocate ,
Jan 19, 2012

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2012 1
New Here ,
Jun 28, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 28, 2019 0
Adobe Community Professional ,
Jun 28, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 28, 2019 0
New Here ,
Jun 28, 2019

Copy link to clipboard

Copied

Lynne,

Thank you for your detailed reply. I was able to get some of my cross references to show up on importing XML via modifications to my EDD, DTD, and R/W rules. What I am noticing now is that the cross references that were tied to tables are the ones that still aren't showing up. Upon looking in structured view, it appears that the ID of the table is not being set on import. The XML does have the ID listed and my EDD, DTD, and R/W rules all specify that the table has the specific ID. The ID is even showing up in the structured document, just not in the imported XML. It shows the attribute as "Id = <no value>". I think I will need to do some digging to find out why this is. If you have advice on this, I'd love to hear it.

Joseph

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 28, 2019 0
Adobe Community Professional ,
Jun 28, 2019

Copy link to clipboard

Copied

Joseph,

   I don't have time to confirm the details now, but I think you may have encountered a long-standing bug in XML import. I have not tested FM 2019 to see if it has been fixed, but I believe that when FM opens an XML document that comes in as a book, a cross-reference from one book component to a table title or cell in a later book component fails to import in the way you describe. I have worked on projects where the workaround was to use a custom client to fix the incorrect cross-references or to put a container within the title or cell and have the cross-reference point to that container instead of the containing table part.

       --Lynne

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 28, 2019 0
New Here ,
Jun 28, 2019

Copy link to clipboard

Copied

Lynne,

That is interesting. That seems like it could definitely be the issue. The only thing is that I'm only working off of a document, not a book. I don't know if that changes anything with the bug. Currently, the reference is in the table title. When another container was placed into the title, did the link still function the same or similarly as before?

Thanks,

Joseph

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 28, 2019 0
Adobe Community Professional ,
Jul 01, 2019

Copy link to clipboard

Copied

Joseph,

   I do not remember seeing a problem with round-tripping xrefs within a single document. Does your template define all the xref formats you use? If so, can you create a small extract that illustrate the problem and put it somewhere that I can access it?

  I have just completed some testing in FM 2019. I found that when an xref to a table title or table cell was in a different book component than the xref, FM creates a cross-reference to the book component containing the xref rather than the one where the specified ID. Such xrefs are therefore unresolved. I repeated the same test in FM 2017 and FM 12 with the same result.

  Furthermore, xrefs to the table element instead of the table title imported correctly. The xref format used must be defined carefully. Building blocks <$elemparanum> and <$elemparanumonly> retrieve the autonumber of the first paragraph in the table (the title or the first cell in the first row). <$paranum> and <$paranumonly> retrieve the autonumber of the paragraph containing the table anchor; if that paragraph does not have an autonumber, the cross-references does not display any text. I did not test the building blocks that extract text from the paragraph or element, but I assume they work analogously as those that extract autonumbers.

   --Lynne

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 01, 2019 0
New Here ,
Jul 02, 2019

Copy link to clipboard

Copied

Lynne,

The situation you described in your last paragraph seems to be what is happening (at least where the cross-reference element still exists, but displays no text). In fact, the reference contains an idref, but the table title has an Id value of "<no value>" as mentioned before. It seems like the same issue you are describing.

I can email you the structured doc, where the cross reference is working, as well as the file after the xml rountrip finishes, where the cross reference is broken.

Thank you,

Joseph

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 02, 2019 0
Adobe Community Professional ,
Jul 02, 2019

Copy link to clipboard

Copied

Joseph,

  Thank you for sending the files. Your situation is quite different from mine. While you do have an element named Table.Title, it is a container and not a table title. I'd need to see more of your application (at least DTD, r/w rules, template, any XSLT pre- or post-process) to diagnose why the cross-reference does not round-trip.

         --Lynne

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 02, 2019 0
New Here ,
Jul 02, 2019

Copy link to clipboard

Copied

I will send those to you as well.

Thanks,

Joseph

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 02, 2019 0
Contributor ,
Jun 29, 2020

Copy link to clipboard

Copied

Hi Lynne,

I have a similar problem with xref in my DITA project where I use xml format. In the format <link.xref> Figure <$elemparanumonly> I need to replace <$elemparanumonly> with <$paranumonly>. I usually do such format changes using the paragraph designer but in this case there is no style defined for the xref. And I cannot figure out where this format is defined in for the xref in order to replace it as mentioned above.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 29, 2020 0