Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2006, 03:00 AM
Registered User
 
Join Date: Jan 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kanchan_b
Default Interesting Error

Please go through the following cases .
-----------------------INPUT-------------------------------------

<mapping source="Case OK" action="M" [u]description="[+Action][+KeyList]" </u> enddate="2006/01/30">
  <keylist>
        <key name="fulfilledAtPointOfSale" value="Y"/>
    </keylist>

</mapping>

<mapping source="Case I" [u]description="[-Action][+KeyList]"</u> enddate="2006/01/30">
    <keylist>
            <key name="fulfilledAtPointOfSale" value="Y"/>
        </keylist>

</mapping>


<mapping source="Case II" [u]description="[-Action][-KeyList]"</u> enddate="2006/01/30">
  <target product="T1234" suppliercode="Supp123" catalogid="Cat123">
    <featuredefault name="Feature1" value="111"/>
  </target>
</mapping>

------------------------OUTPUT----------------------------------
<mapping source="Case Ok" [u]description="[+Action][+KeyList]"</u> enddate="2006/01/30">
    <keylist>
    <key name="product.action" value="M"/>
    <key name="fulfilledAtPointOfSale" value="Y"/>
    </keylist>
</mapping>

<mapping source="Case I" description="[-Action][+KeyList]" enddate="2006/01/30">
  <keylist>
    <key name="product.action" value=""/>
    <key name="fulfilledAtPointOfSale" value="Y"/>
  </keylist>
</mapping>

<mapping source="Case II" description="[-Action][-KeyList]" enddate="2006/01/30">
 <target product="T1234" suppliercode="Supp123" catalogid="Cat123">
    <featuredefault name="Feature1" value="111"/>
 </target>
</mapping>
-------------------------XSLT-------------------------------
<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" media-type="text/xml"/>

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

 <xsl:template match="mapping">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:if test="@action">
            <xsl:choose>
                <xsl:when test="keylist">
                   <xsl:apply-templates select="mapping/keylist"/>
            </xsl:when>
            <xsl:otherwise>
                     <keylist>
                      <key name="product.action" value="{@action}"/>
                     </keylist>
            </xsl:otherwise>
            </xsl:choose>
      </xsl:if>
      <xsl:apply-templates select="*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="mapping/@action" />

  <xsl:template match="mapping/keylist">
          <xsl:copy>
           <key name="product.action" value="{../@action}"/>
           <xsl:apply-templates select="*"/>
           </xsl:copy>
  </xsl:template>


---------------------------------------------------------
Issues
1)I want to replace @action with <Keylist><key>...<key></keylist>
2)Transformation is as required in Case Ok
3)Case I , even if there is no @action the <key>..value=""</key> has been populated
4) Case II , the <keylist> is not added in this case as @action is missing

I have also copied the XSLT which is giving this effect

Help me finding the error in my XSLT. I m using XMLSPY for my transformation

Thanks in advance , awaiting your solutions.


Cheers
Kanchan




 
Old February 1st, 2006, 03:10 AM
Registered User
 
Join Date: Jan 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kanchan_b
Default

OOps
Got My mistake ...

Thanks anyways
Kanchan






Similar Threads
Thread Thread Starter Forum Replies Last Post
An interesting question iPagan BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 February 13th, 2007 05:31 PM
Photo Album - interesting error abel714 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 8 January 4th, 2007 06:29 PM
Interesting Problem prasanta2expert ASP.NET 1.0 and 1.1 Basics 1 October 16th, 2006 08:14 PM
How shall I make the game interesting? flash2004 Need help with your homework? 0 June 11th, 2006 10:17 PM
Interesting validation problem jacob ASP.NET 1.0 and 1.1 Professional 5 February 16th, 2006 07:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.