0

My goal is to use this XSLT stylesheet to remove the entire LoanSecondaryStatus node when the StatusDate is 1900-01-01T00:00:00, but otherwise keep the node when it is any other date.

I have the following XML:

<Loans>
   <Loan>
       <LoanSecondaryStatus>
          <StatusName>Application Started</StatusName>
          <StatusDate>1900-01-01T00:00:00</StatusDate>
      </LoanSecondaryStatus>
      <LoanSecondaryStatus>
          <StatusName>Application Finished</StatusName>
          <StatusDate>2016-03-02T00:00:00</StatusDate>
      </LoanSecondaryStatus>
  </Loan>
</Loans>

And here is the XSLT i'm using to try and remove the LoanSecondaryStatus node:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output indent="yes" />

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

  <xsl:template match="/LoanSecondaryStatus[not(StatusDate='1900-01-01T00:00:00')]"/>
</xsl:stylesheet>

1 Answer 1

1

remove the entire LoanSecondaryStatus node when the StatusDate is 1900-01-01T00:00:00

I believe your 2nd template needs to be:

<xsl:template match="LoanSecondaryStatus[StatusDate='1900-01-01T00:00:00']"/>
Sign up to request clarification or add additional context in comments.

2 Comments

Yup that worked. How does that work without the "not"?
@dc922 Your 1st template is the identity transform template. It copies everything as is. The 2nd template provides an exception. It matches the node you want to remove and outputs nothing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.