Loading ...
Sorry, an error occurred while loading the content.

Processing a conditional element

Expand Messages
  • rickprice407
    I have an XML file that may or may not contain a certain element. If it exists then a child element will reference it, otherwise the child must refernce
    Message 1 of 2 , Apr 28, 2003
    • 0 Attachment
      I have an XML file that may or may not contain a certain element. If
      it exists then a child element will reference it, otherwise the child
      must refernce another element. I'm not sure how to specify

      If optional element exists then
      Child element references optional element
      Else child element references other required element

      Any help greatly appreciated.

      Rick Price
    • G. Ken Holman
      XSLT and XPath questions would be better posted to the following list: http://www.mulberrytech.com/xsl/xsl-list There are a number of subscribers who would
      Message 2 of 2 , Apr 28, 2003
      • 0 Attachment
        XSLT and XPath questions would be better posted to the following list:

        http://www.mulberrytech.com/xsl/xsl-list

        There are a number of subscribers who would enthusiastically respond to
        such questions.

        There is also an *excellent* FAQ at:

        http://www.dpawson.co.uk

        At 2003-04-28 18:45 +0000, rickprice407 wrote:
        >I have an XML file that may or may not contain a certain element. If
        >it exists then a child element will reference it, otherwise the child
        >must refernce another element. I'm not sure how to specify
        >
        >If optional element exists then
        > Child element references optional element
        >Else child element references other required element

        <xsl:choose>
        <xsl:when test="XPath address to optional element">
        <child-goes-here ...>
        </xsl:when>
        <xsl:otherwise>
        <child-goes-here ...>
        </xsl:otherwise>
        </xsl:choose>

        I hope this helps.

        ................... Ken

        --
        Upcoming hands-on courses: Europe (XSLT/XPath): May 5, 2003
        - Europe (XSL-FO): May 16, 2003
        - (XSLT/XPath and/or XSL-FO) North America: June 16-20, 2003

        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
        ISBN 0-13-065196-6 Definitive XSLT and XPath
        ISBN 0-13-140374-5 Definitive XSL-FO
        ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
        ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
        Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
      Your message has been successfully submitted and would be delivered to recipients shortly.