Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3754508
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:33:20+00:00 2026-05-19T09:33:20+00:00

I have an xml file which I need to transform with XSLT. In my

  • 0

I have an xml file which I need to transform with XSLT. In my XSLT file I’m doing a number of things with the xml file. I first copy all elements; then I rename some of the elements. Lastly I need to remove for output any dealer-code element that has a dealer-code-name of 0. The 1st 2 pieces I have working, but I’ve tried every piece of code I’ve found online and can’t seem to remove those offending dealer-code elements. I’m new to XSLT so I may be doing it all wrong; any help would be appreciated.

Partial xml code:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <?xml-stylesheet type="text/xsl" href="xmlstructure.xsl"?>
 <AdBaseData>
  <AdBasePreprintInfo FromDistribute="true">
       <PreprintInsert>
        <Sides>2</Sides>
        <PageCount>2</PageCount>
        <InsertSchedule>
            <AdLocInfo>
                <rundates>
                    <date>12042010</date>
                </rundates>
            </AdLocInfo>
            <invoice-text>South Plaza - Stalker Advertisin</invoice-text>
            <BillingOverride Type="Subscriber">49996</BillingOverride>
            <deal-code0>
                <dealer-code-name>A20</dealer-code-name>
                <Delivery-Method Type="Subscriber">
                    <Selected>true</Selected>
                </Delivery-Method>
            </deal-code0>
            <deal-code1>
                <dealer-code-name>0</dealer-code-name>
                <Delivery-Method Type="Subscriber">
                    <Selected>true</Selected>
                </Delivery-Method>
            </deal-code1>
  </InsertSchedule>
</PreprintInsert>

My xslt:

   <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
     <xsl:template match="@* | node()">
       <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
       </xsl:copy>
     </xsl:template>
    <xsl:template match="*[starts-with(name(), 'deal-code')]">
       <xsl:element name="dealer-code">
         <xsl:apply-templates/>
       </xsl:element>
     </xsl:template>
     <xsl:template match="dealer-code[@dealer-code-name='0']">
     </xsl:template>
    </xsl:stylesheet>

The rename of deal-code to dealer-code works. However, the last part to not output any dealer-code-name with a value of 0 does not. My resulting xml file still lists every dealer-code element.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:33:21+00:00Added an answer on May 19, 2026 at 9:33 am

    You have two problems:

    1. You do not have any dealer-code elements in the source XML. They are deal-code0 and deal-code1
    2. dealer-code-name is an element, not an attribute.

    Your XPATH currently matches dealer-code elements with @dealer-code-name='0'. Since there are no dealer-code elements and there are no dealer-code-name attributes, it never matches and does not suppress the content.

    You need to adjust your XPATH to match the deal-code elements similar to how you are in the other template and add an additional predicate filter for child elements dealer-code-name with a value of 0. Additionally, since both of your templates have similar matching logic, they may get the same priority level. You may need to bump up the priority of this redaction template, so that it “wins” against the more generic match:

     <xsl:template match="*[starts-with(name(), 'deal-code') and dealer-code-name='0']" priority="1"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file which describes (among other things) elements with attribute values
I have xml/rdf file which I get from service. So, I need to transform
I have an input XML file which I need to copy 1:1 to the
I have an XML file which I need to modify. First I need to
I have an XML file which I need to parse using PHP and send
HI I have an xml file with 500KB size which i need to send
I have an XML file which has to be transformed using XSLT, I am
I have an XML file which I need to read and load the data
i have xml file which contains CDATA i need to update the CDATA as
need help to read xml file. i have one xml file which i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.