Page 1 of 1

wrap multiple <p> tags for conditional processing

Posted: Tue Jul 09, 2024 1:02 pm
by petrepavlov
Hi,

Is there a way to wrap multiple consecutive <p> tags with a single tag for conditional processing?
Example:
<p> This is line 1.</p>
<p>This is line 2.</p>
<p>This is line 3.</p>
.
.
.
<p>This is line N.</p>



I would like to conditionalize all N <p> tags at once, instead of using <ph> to wrap each <p> tag content individually.

Re: wrap multiple <p> tags for conditional processing

Posted: Tue Jul 09, 2024 1:30 pm
by cosminef
Hello,

You can wrap multiple consecutive <p> elements in a DITA <div> [1].

[1] https://www.oxygenxml.com/dita/1.3/spec ... e/div.html

Best,
Cosmin

Re: wrap multiple <p> tags for conditional processing

Posted: Tue Jul 09, 2024 3:26 pm
by petrepavlov
Thank you Cosmin.
I tried but the <div> tag is no allowed in the .dita files I am currently working on.
Any idea why?
image.png
image.png (19.53 KiB) Viewed 368 times

Re: wrap multiple <p> tags for conditional processing

Posted: Tue Jul 09, 2024 4:19 pm
by cosminef
Hello,

You can try selecting the desired paragraphs, pressing ENTER, and then choosing <div> to wrap them.

Best,
Cosmin

Re: wrap multiple <p> tags for conditional processing

Posted: Tue Jul 09, 2024 5:26 pm
by petrepavlov
cosminef wrote: Tue Jul 09, 2024 4:19 pm You can try selecting the desired paragraphs, pressing ENTER, and then choosing <div> to wrap them.


I also tried this with no success.

Re: wrap multiple <p> tags for conditional processing

Posted: Wed Jul 10, 2024 6:46 am
by Radu
Hi,
How about if you try to create a new DITA XML topic file with the contents:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic_f35_rtx_zbc">
    <title>Title</title>
    <body>
    <div>
      <p>Some paragraph1</p>
      <p>Some paragraph2</p>
    </div>
    </body>
</topic>
? Do you get validation errors in the topic? In general the <div> element can be used as a wrapped for block type elements like in my example above.
Regards,
Radu

Re: wrap multiple <p> tags for conditional processing

Posted: Wed Jul 10, 2024 10:45 am
by petrepavlov
Hi Radu,
No validation errors when pasting the code below in a new DITA XML file. Any idea what to look for in my book?
Thanks.
image.png
image.png (29.17 KiB) Viewed 307 times

Re: wrap multiple <p> tags for conditional processing

Posted: Wed Jul 10, 2024 11:47 am
by Radu
Hi,
I do not know what type of DITA XML topics you are working with, maybe you are using a DITA XML specialization which does not allow the use of the <div> element, this is not something we can control.
Regards,
Radu

Re: wrap multiple <p> tags for conditional processing

Posted: Wed Jul 10, 2024 1:55 pm
by petrepavlov
This is the XML for an actual file I am working on. Is this info enough to offer some suggestion?
image.png
image.png (12.86 KiB) Viewed 295 times

Re: wrap multiple <p> tags for conditional processing

Posted: Thu Jul 11, 2024 7:27 am
by Radu
Hi,
The <div> element can also be used inside DITA XML concept files, so something like this should be valid also on your side:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="concept_n2l_bgf_1cc">
    <title>Test</title>
    <conbody>
    <div>
      <p>Some para1</p>
      <p>Some para2</p>
    </div>
  </conbody>
</concept>
I think that maybe you had trouble inserting the <div> in the Author visual editing mode because you attempted to insert it inside a paragraph and not before or after a paragraph.
Regards,
Radu

Re: wrap multiple <p> tags for conditional processing

Posted: Thu Jul 11, 2024 1:15 pm
by petrepavlov
Hi Radu,
It worked surronunding with <div></div> the concerned elements in text mode. Thank you!!!
However I cannot seem to surround with <div> several elements in Author mode. I tried:
- selecting the concerned elements and pressing [ENTER]
- inserting <div> outside <p> or any element that needed to be profiled
- using Refactoring -> Elements -> Wrap Element.
Is there any option that I might have missed in Author mode?
Should the option "Allow only insertion of valid elements and attributes" be disabled for this? How?
image.png
image.png (20.36 KiB) Viewed 256 times

Re: wrap multiple <p> tags for conditional processing

Posted: Thu Jul 11, 2024 1:32 pm
by Radu
Hi,
I'm not sure how you select the paragraphs, do you select them one by one by using the mouse? I'm selecting them by using shift with arrows starting before the first one and ending after the last one and things seem to work for me:
Screenshot 2024-07-11 at 13.19.59.png
Screenshot 2024-07-11 at 13.19.59.png (38.33 KiB) Viewed 253 times
Anyway, here's a workaround, select the paragraphs as you want, Ctrl-X to cut them, ENTER, insert the <div> and then paste the content inside the <div>.
Regards,
Radu

Re: wrap multiple <p> tags for conditional processing

Posted: Mon Jul 15, 2024 3:43 pm
by petrepavlov
Hi Radu,
Actually inserting <div> in Author mode does not work at all. I tried in several files and in a dummy file with the same result.
In the dummy file screenshot I try to insert <div> between the last two <p> elements.
In Text mode I can place a <div>, move the paragraphs, and print the pdf successfully.
Is there any option which could potentially block the insertion in Author mode?
Regards,
Petre
image.png
image.png (38.59 KiB) Viewed 153 times

Re: wrap multiple <p> tags for conditional processing

Posted: Mon Jul 15, 2024 7:28 pm
by Radu
Hi Petre,
Is it possible that you have installed in Oxygen a DITA framework customization created by you or by someone in your company which changes the list of allowed elements in the Oxygen content completion window?
This kind of customization is usually done with an XML configuration file:
https://www.oxygenxml.com/doc/versions/ ... t-elements
Because this would explain why the DITA topic is shown as valid when the <div> is inserted manually in the Text editing mode but you are not allowed to insert it in the content completion window.
Regards,
Radu