• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Validation before or after XSLT

Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

I am creating a FrameMaker structured application where I have to save the content as XML. I am going to apply XSLT on the export. Does the content get validated against the DTD before or after the XSLT transform?

TOPICS
Structured

Views

148

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
community guidelines

correct answers 1 Correct answer

Mentor , May 03, 2022 May 03, 2022

Hi Rick. It is before. The DTD or schema applies to the exported XML before it is transformed and written to disk. The opposite is true when opening a file with an import stylesheet... the DTD/schema is applied to the data after the transform. So basically the XML on disk can be anything.

 

Older versions of FM used to skip the transform if the validation failed. This could be a problem if there was a crash right after the save (not that FM ever crashes, mind you 🙂 You could end up with an XML fi

...

Votes

Translate

Translate
Mentor ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

Hi Rick. It is before. The DTD or schema applies to the exported XML before it is transformed and written to disk. The opposite is true when opening a file with an import stylesheet... the DTD/schema is applied to the data after the transform. So basically the XML on disk can be anything.

 

Older versions of FM used to skip the transform if the validation failed. This could be a problem if there was a crash right after the save (not that FM ever crashes, mind you 🙂 You could end up with an XML file on disk with a structure incompatible with your import application, which logically would include a transform in the other direction. With FM2019 and later, it seems that it attempts the transform no matter what is the outcome of the validation, which I think is a much better approach.

 

Russ

Votes

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
community guidelines
Community Expert ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

Thank you Russ. My EDD is going to be slightly different than the DTD to facilitate some editing conveniences for the authors. But I am going to use XSLT to make the XML conform to the DTD. As a result, I was hoping that the validation against the DTD would be after the transform. They will just have to make sure the document is valid in FrameMaker and ignore the Console messages on export. Thanks again for the clarification! -Rick

Votes

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
community guidelines
Advisor ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

Sorry I'm so late to join the conversation. This note explains why Russ's answer has to be correct. There are actually two different arguments for reaching the same conclusion:

 

1) Consider two XML applications that are identical except that one has an XSLT postprocess and the other does not. If you export a document with the one without a postprocess that result uses the DTD provided in the application. But that output is identical to the preliminary result produced by the application with the postprocess. Thus, the DTD specified in the application definition has to be used by the preliminary result.

 

2) When you save a FrameMaker document as XML, FrameMaker includes the name of the DTD in the document type declaration, but it also uses information in the DTD, the read/write rules, and the FrameMaker document to determine how to represent the FrameMaker content in XML. When an XML application has an XSLT postprocess, the generated structure may be quite different from the one used in FrameMaker--elements may be added, removed, or rearranged, information can move between elements and attributes, and so forth. There may be a DTD or schema for this final result but the correspondence between the structure used within FrameMaker and the output of the postprocess cannot be deduced automatically. Thus any DTD used for the final result must be provided outside of FrameMaker and the XSLT transform must generate the reference to this second DTD. 

 

Again, as Russ also pointed out, when there is a preprocess, the DTD is used by the output of the preprocess. The logic to understand why this must be the case is the reverse of the above. The initial XML document may used a different structure than that used in FrameMaker. The transform changes that to the structure that is used by FrameMaker and imports that temporary result using a structure that is very close to the one used by FrameMaker.

 

In summary, a diagram of the processing with a postprocess is:

      FrameMaker -> temporary XML -> final XML

A diagram of a preprocess is:

      Original XML -> temporary XML -> FrameMaker

In both cases, the temporary XML uses the DTD that is closely related to the EDD.

 

I hope this made sense and makes it easier to understand.

 

    --Lynne

Votes

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
community guidelines
Community Expert ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

LATEST

Thank you for the detailed explanation Lynne. It makes sense.

Votes

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
community guidelines