[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Preserving CDATA sections?

Subject: Re: [xsl] Preserving CDATA sections?
From: Dan Vint <dvint@xxxxxxxxx>
Date: Fri, 14 Dec 2012 17:54:39 -0800

Interesting idea using a custom element. I should have mentioned that my intention is to remove this CDATA content as part of the review and cleanup step at the end. The conversion team will be going through all the data modules to make sure nothing was lost in the conversion as well as enhancing some information that needs a human touch to create. I was trying to preserve the original markup incase there was a problem and it needed to be replaced. It would just be a cut and paste in the one file rather than having to go back to the source files.

I was really surprised when the <xsl:comment> approach didn't work. I didn't expect the markup to be stripped by that process. That was my first attempt that helped to find the changes in the original source. This was ok until I found a need to preserve the content in case I stripped too much while removing the change markup. The result of that also hide the issue of comments inside comments as they were stripped in this first attempt as well.

I'll give these ideas a try on Monday. Thanks


At 05:31 PM 12/14/2012, you wrote:

Anyone have ideas for an alternate solution?

Run your pipeline putting the old content you want to preserve into a custom element in a custom namespace. Your new content then has both the old content and the new content for you to visually do your comparison at the end of your pipeline to see what has changed.

At those points in your pipeline where you need to use an S1000D document model to validate an intermediate file, preprocess that file to strip out your custom element so that it doesn't trigger any problems.

And that stripping stylesheet will be handy when you are all done in order to remove the old content from the new file so that you only have the new file.

And the stripping stylesheet is small: only two template rules. One template rule catches all elements in your custom namespace and does nothing with them. The other template rule is the idiomatic identity template. Easy to write. Easy to use. Any time you need an intermediate file to produce a final output of some kind, just pre-process it and use your existing processes.

This is a scheme that doesn't use disable-output-escaping= and will work whether you serialize your intermediate files to output entities or pass intermediate trees from process to process. You don't have to worry about writing your own XML serialization logic (in XSLT of all languages!) and it will work regardless of what imaginative markup comes from your authors.

I hope this helps.

. . . . . . . . . . . Ken

Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

--------------------------------------------------------------------------- Danny Vint

Panoramic Photography

voice: 619-938-3610

Current Thread