xml - XSLT: Add line breaks before preserve space elements -


This is my last question for line breaks before preserving space elements.

This,

  & lt; Content & gt; & Lt; TitleGroup & gt; & Lt; Title & gt; Text & lt; / Title & gt; & Lt; / TitleGroup & gt; & Lt; Creators1 & gt; & Lt; Manufacturer & gt; & Lt; PERSONNAME & gt; & Lt; Name & gt; John & lt; / Name & gt; & Lt; / PERSONNAME & gt; & Lt; / Creator & gt; & Lt; / Creators1 & gt; & Lt; Creators2 & gt; & Lt; Affiliation & gt; & Lt; OrgDiv & gt; Text & lt; / OrgDiv & gt; & Lt; Address & gt; & Lt; Country & gt; Britain & lt; / Country & gt; & Lt; / Address & gt; & Lt; / Affiliation & gt; & Lt; / Creators2 & gt; & Lt; / Content & gt;   

I used the following Xsl:

   & Lt; Xsl: strip-space element = "*" /> & Lt; Xsl: protected-space element = "creator1 builder" /> & Lt; Xsl: template match = "/" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: apply-select template = "@ * | node ()" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;   

The output produced by this XML,

  & lt; Content & gt; & Lt; Title group & gt; Title & gt; Text & lt; / Title & gt; & Lt; / TitleGroup & gt; & Lt; Creators1 & gt; & Lt; Manufacturer & gt; & Lt; PERSONNAME & gt; & Lt; Name & gt; John & lt; / Name & gt; & Lt; / PERSONNAME & gt; & Lt; / Creator & gt; & Lt; / Creators1 & gt; & Lt; Creators2 & gt; & Lt; Affiliation & gt; & Lt; OrgDiv & gt; Text & lt; / OrgDiv & gt; & Lt; Address & gt; & Lt; Country & gt; Britain & lt; / Country & gt; & Lt; / Address & gt; & Lt; / Affiliation & gt; & Lt; / Creators2 & gt; & Lt; / Content & gt;   

But I need a line break before element in the list of elements, after that place after the element (need to start and end a tag in one line) No,

  & lt; Content & gt; & Lt; Title group & gt; & Lt; Title & gt; Text & lt; / Title & gt; & Lt; / TitleGroup & gt; & Lt; Creators1 & gt; & Lt; Manufacturer & gt; & Lt; PERSONNAME & gt; & Lt; Name & gt; John & lt; / Name & gt; & Lt; / PERSONNAME & gt; & Lt; / Creator & gt; & Lt; / Creators1 & gt; & Lt; Creators2 & gt; & Lt; Affiliation & gt; & Lt; OrgDiv & gt; Text & lt; / OrgDiv & gt; & Lt; Address & gt; & Lt; Country & gt; Britain & lt; / Country & gt; & Lt; / Address & gt; & Lt; / Affiliation & gt; & Lt; / Creators2 & gt; & Lt; / Content & gt;   

I have to give a line break at the end of the header as well as at the end of the creators too.

pls do not give suggestions & lt; Xsl: text & gt; & Lt; / Xsl: text & gt; Like the use I need to use it to preserve the location or any other way.

Thank you.

Obviously this depends on how much you are processing on MSXSL 3 ( Which I assumed was the namespace), removing the output mode, getting rid of the space, and putting the text into space

   & Lt; Xsl: template match = "@ * | node ()" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: apply-select template = "@ * | node ()" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "creators1 | creators2" & gt; & Lt; XSL: Text & gt; & Lt; / XSL: text & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: apply-select template = "@ * | node ()" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;   

gives you:

  & lt ;? XML version = "1.0" encoding = "UTF-16"? & Gt; & Lt; Content & gt; & Lt; Title group & gt; & Lt; Title & gt; Text & lt; / Title & gt; & Lt; / TitleGroup & gt; & Lt; Creators1 & gt; & Lt; Manufacturer & gt; & Lt; PERSONNAME & gt; & Lt; Name & gt; John & lt; / Name & gt; & Lt; / PERSONNAME & gt; & Lt; / Creator & gt; & Lt; / Creators1 & gt; & Lt; Creators2 & gt; & Lt; Affiliation & gt; & Lt; OrgDiv & gt; Text & lt; / OrgDiv & gt; & Lt; Address & gt; & Lt; Country & gt; Britain & lt; / Country & gt; & Lt; / Address & gt; & Lt; / Affiliation & gt; & Lt; / Creators2 & gt; & Lt; / Content & gt; Something similar in   

and Xalan and Saxon

Comments