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

Drop an element based on the value of an attribute but retain children

New Here ,
Aug 19, 2025 Aug 19, 2025

Hi there,

Brand new to FrameMaker and grateful for any help!

I have several elements that contain text in my XML that I want FrameMaker to omit if the attribute display="false" is present? Can I drop/omit an element based on an attribute's value, but not drop the child element?

 

example:

<option1>
  <feedisplay display="true">Text in the output</feedisplay>
    <option2>
      <feedisplay display="true">Text in the output</feedisplay>
        <option3>
          <feedisplay display="false">Text I want ignored/omitted in the output</feedisplay>
            <option4>
              <feedisplay display="true">Text in the output</feedisplay>

 

123
Translate
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 ,
Aug 19, 2025 Aug 19, 2025

Do you want to omit it from FrameMaker on import from XML? Or do you want to see it in FrameMaker but omit it when you save as XML?

 

Either way, can you post an after sample of your XML? Thanks.

Translate
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 ,
Aug 19, 2025 Aug 19, 2025

Would this be your sample input with the nesting in place?

<?xml version="1.0" encoding="UTF-8"?>
<option1>
    <feedisplay display="true">Text in the output</feedisplay>
    <option2>
        <feedisplay display="true">Text in the output</feedisplay>
        <option3>
            <feedisplay display="false">Text I want ignored/omitted in the output</feedisplay>
            <option4>
                <feedisplay display="true">Text in the output</feedisplay>
            </option4>
        </option3>
    </option2>
</option1>
Translate
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
New Here ,
Aug 20, 2025 Aug 20, 2025
LATEST

Good morning Frameexpert!

Yes, your example of the input is correct. Thank you for your help! I've tried drop and unwrap with no such luck. I'm importing the XML and the output is a pdf which I do not want that text included in. I hope that helps clarify things. 🙂

Translate
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 ,
Aug 20, 2025 Aug 20, 2025

This XSL stylesheet, which can be applied to your content on export to XML,

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="3.0">
    
    <xsl:output indent="1"/>
    
    <xsl:template match="feedisplay[@display='false']">
        <xsl:apply-templates select="*"/>
    </xsl:template>    
    
    <xsl:mode on-no-match="shallow-copy"/>
    
</xsl:stylesheet>

will give you this output:

<?xml version="1.0" encoding="UTF-8"?>
<option1>
   <feedisplay display="true">Text in the output</feedisplay>
   <option2>
      <feedisplay display="true">Text in the output</feedisplay>
      <option3>
         <option4>
            <feedisplay display="true">Text in the output</feedisplay>
         </option4>
      </option3>
   </option2>
</option1>
Translate
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