p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Err,This document already has DocumentElement node (http://p2p.wrox.com/showthread.php?t=64792)

ismailc December 24th, 2007 07:54 AM

Err,This document already has DocumentElement node
 
Hi, I need help please!

I'm trying to incorporate an html code that uses to an js & css files.
The files are okay, i think problem comes where I want to give another value to the ID!

Code:
<style type='text/css' media='all'>
@import 'tooltip/css/global.css';
</style>
<script src='tooltip/js/jquery.js' type='text/javascript'></script>
<script src='tooltip/js/jtip.js' type='text/javascript'></script>

<xsl:if test="Tooltip != ''">
 <xsl:element name="asp:image">
 <xsl:attribute name='id'>one

 </xsl:attribute>


 <a>
  <xsl:attribute name='href'>ajax.htm</xsl:attribute>
  <xsl:attribute name='class'>jTip</xsl:attribute>

   ?</a>



</xsl:element>

</xsl:if>


Please Assist!

Regards



Martin Honnen December 24th, 2007 08:27 AM

Well what problem exactly do you have?
You have posted a snippet of XSLT that tries to attempt to generate an ASP.NET server-side control named 'asp:image'. That alone can be a problem later, unless you parse the result of that XSLT stylesheet with ASP.NET the asp:image element will not be recognized and understood.
So currently it is not clear what you want to achieve and what the exact problem is. If the stylesheet does not do what you want it to do then that can obviously also depend on the XML input that you do not show at all.


ismailc December 24th, 2007 08:47 AM

Hi, Thank You for the assist, I found via the net a workaround for a tooltip 'alt' but it timesout.
i want to incorporate the below code to an existing xslt file where i get rid of the alt on the TOOLTIP & replace it by href.

[u]Workaround 'Alt' in HTML</u>
[code]
<style type="text/css" media="all">
@import "css/global.css";
</style>

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jtip.js" type="text/javascript"></script>

<a id="one" href="ajax.htm" class="jTip">?</a>


[u]Existing XSLT FILE </u>[code]
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:asp="remove" xmlns:igchart="remove" xmlns:igsch="remove">
<xsl:output omit-xml-declaration = "yes" />
<xsl:template match="/">
<table width="100%" class="tbDetail">

    <tr>
        <td>
            <SCRIPT TYPE='text/javascript'>
                function hideHist()
                {
                    if (typeof fcHist != 'undefined')
                    {
                        fcHist.style.display = 'none';
                    }
                }
            </SCRIPT>
        </td>
    </tr>
    <xsl:variable name="cHist" select="count(Activity/myTracking/Activity[ DateResolved != '0' ])" />
    <xsl:if test="$cHist &gt; '0'">
        <tr width="100%">
            <td colspan="6" class="row1">
                <SCRIPT TYPE='text/javascript'>
                    function toggleHist(srcElement, srcArrow) {
                        if (srcElement.style.display == 'none')
                        {
                            srcElement.style.display = '';
                            srcArrow.src = 'images/expand.gif';
                        } else
                        {
                            srcElement.style.display = 'none';
                            srcArrow.src = 'images/collapse.gif';
                        }
                    }
                </SCRIPT>
                <span id='fcHistMain' style='cursor:hand;' onclick='toggleHist(fcHist, fcExpand)'>
                    <span style="vertical-align:middle;">
                        <img src='images/collapse.gif' id='fcExpand' align="middle" />#160;Expand to view the History
                    </span>
                </span>
            </td>
        </tr>
        <tr>
            <td colspan="6">
                <div id='fcHist'>
                    <table width='100%' class='tbList'>
                    <xsl:for-each select="Activity/myTracking/Activity[ DateResolved != '0' ]">
                        <xsl:sort select='@id' />
                        <tr>
                            <td width='5%'><xsl:attribute name='class'><xsl:if test="position() mod 2 = 1">on</xsl:if><xsl:if test="position() mod 2 != 1">off</xsl:if></xsl:attribute><xsl:value-of select="position()" />.#160;</td>
                            <td width='55%'><xsl:attribute name='class'><xsl:if test="position() mod 2 = 1">on</xsl:if><xsl:if test="position() mod 2 != 1">off</xsl:if></xsl:attribute>
                                <xsl:if test="TrackValues = 'False'">
                                    <xsl:value-of select="Description" />
                                </xsl:if>
                                <xsl:if test="TrackValues = 'True' or TrackValues = ''">
                                    <a>
                                        <xsl:attribute name='href'>myTrackingPage.aspx?type=a&amp;id=<xsl :value-of select="@id" /></xsl:attribute>
                                        <xsl:attribute name='class'>bn</xsl:attribute>
                                        <xsl:value-of select="Description" />
                                    </a>
                                </xsl:if>
                            </td>
                            <td width='20%'><xsl:attribute name='class'><xsl:if test="position() mod 2 = 1">on</xsl:if><xsl:if test="position() mod 2 != 1">off</xsl:if></xsl:attribute>
                                <xsl:if test="CreatorEMail[. = '']"><xsl:value-of select="Creator" /></xsl:if>
                                <xsl:if test="CreatorEMail[. != '']">
                                <a>
                                    <xsl:attribute name='class'>bn</xsl:attribute>
                                    <xsl:attribute name='href'>mailto:<xsl:value-of select="CreatorEMail" />?Subject=<xsl:value-of select="Description" /></xsl:attribute>
                                    <xsl:value-of select="Creator" />
                                </a>
                                </xsl:if>
                            </td>
                            <td width='20%'>
                                <xsl:attribute name='class'><xsl:if test="position() mod 2 = 1">on</xsl:if><xsl:if test="position() mod 2 != 1">off</xsl:if></xsl:attribute>
                                <xsl:value-of select="substring(DateResolved,1,4)"/>/<xsl:value-of select="substring(DateResolved,5,2)"/>/<xsl:value-of select="substring(DateResolved,7,2)" />#160;
                                <xsl:value-of select="substring(TimeResolved,1,2)" />:<xsl:value-of select="substring(TimeResolved,3,2)" />:<xsl:value-of select="substring(TimeResolved,5,2)" />
                            </td>
                        </tr>
                    </xsl:for-each>
                    </table>
                </div>
            </td>
        </tr>
    </xsl:if>


    <xsl:for-each select="Activity/ObjectGroup[@type='default']/Object">
    <xsl:sort select="@index" data-type="number" />
    <xsl:variable name="index" select="@index" />
    <xsl:variable name="nextNode" select="../Object[ @index > $index ][1]" />
    <xsl:variable name="nextCol" select="$nextNode/@columnNo" />
    <xsl:variable name="vis" select="string(Attributes/Attribute[ @name='visible'])" />
    <xsl:variable name="visNextCol" select="string($nextNode/Attributes/Attribute[ @name='visible'])" />
    <xsl:if test="($vis != 'False') or ($nextCol = '2' and ($vis != 'False' or $visNextCol != 'False'))">
    <xsl:if test="(@columnNo != '2')">
    <tr class="rowDetail">


        <xsl:choose>
        <xsl:when test="(string(Attributes/Attribute[ @name='visible']) = '') or (Attributes/Attribute[ @name='visible'] != 'False')">

            <td width='15%' align='left' class='rowDet'>
                <xsl:value-of select="Description" disable-output-escaping="yes" />#160;
                <xsl:if test="Mask[. != '']">(<xsl:value-of select="Mask" />)#160;</xsl:if>

        <xsl:if test=" @required[. = 'true']"></xsl:if>#160;
            </td>
            <td valign="middle">
                <xsl:if test="($nextCol != '2') or (count(following-sibling::*) = 0) or ($nextCol = '2' and $visNextCol = 'False')">
                    <xsl:attribute name='colspan'>4</xsl:attribute>
                    <xsl:attribute name='width'>70%</xsl:attribute>
                </xsl:if>
                <xsl:call-template name="CreateObject">
                    <xsl:with-param name="Object" select="." />
                </xsl:call-template>
                <xsl:if test="Tooltip != ''">
                #160;
                <xsl:element name="asp:image">
                    <xsl:attribute name='id'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:attribute name='imageurl'>images/tooltip.gif</xsl:attribute>
                    <xsl:attribute name='alt'><xsl:value-of select="Tooltip" /></xsl:attribute>
                </xsl:element>
                </xsl:if>
            </td>
            <td width='5%' align="right">
      <!--
            <xsl:if test="@dynamic='true'">
                <xsl:element name="asp:imageButton">
                    <xsl:attribute name='id'>reload_<xsl:value-of select='@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:attribute name='imageurl'>images/reload.gif</xsl:attribute>
                    <xsl:attribute name='alt'>Reload <xsl:value-of select="Description" /></xsl:attribute>
                </xsl:element>
            </xsl:if>
      -->
            </td>

        </xsl:when>
        <xsl:otherwise>
            <td width='15%' align='right' class='rowDet'>#160;</td>
            <td valign="middle">#160;</td>
            <td width='5%' align="right">#160;</td>
        </xsl:otherwise>
        </xsl:choose>

        <xsl:if test="($nextCol = '2') and $visNextCol != 'False'">

            <td width='15%' align='left' class='rowDet'>
                <xsl:value-of select="$nextNode/Description" disable-output-escaping="yes" />#160;
                <xsl:if test="$nextNode/Mask[. != '']">(<xsl:value-of select="$nextNode/Mask" />)#160;</xsl:if>

        <xsl:if test=" @required[. = 'true']"></xsl:if>#160;
            </td>
            <td width='30%' valign="middle">
                <xsl:call-template name="CreateObject">
                    <xsl:with-param name="Object" select="$nextNode" />
                </xsl:call-template>
                <xsl:if test="$nextNode/Tooltip != ''">
                #160;
                <xsl:element name="asp:image">
                    <xsl:attribute name='id'>ttip_<xsl:value-of select='$nextNode/@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:attribute name='imageurl'>images/tooltip.gif</xsl:attribute>
                    <xsl:attribute name='alt'><xsl:value-of select="$nextNode/Tooltip" /></xsl:attribute>
                </xsl:element>
                </xsl:if>
            </td>
            <td width='5%' align="right">
            <!--
       <xsl:if test="$nextNode/@dynamic='true'">
                <xsl:element name="asp:imageButton">
                    <xsl:attribute name='id'>reload_<xsl:value-of select='$nextNode/@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:attribute name='imageurl'>images/reload.gif</xsl:attribute>
                    <xsl:attribute name='alt'>Reload <xsl:value-of select="$nextNode/Description" /></xsl:attribute>
                </xsl:element>
            </xsl:if>
      -->
            </td>
        </xsl:if>
    </tr>
    </xsl:if>
    </xsl:if>
    </xsl:for-each>


    <xsl:for-each select="Activity/ObjectGroup[@type='group'][ @visible='true' ]">
    <xsl:sort select="@name" />
    <xsl:variable name="tmpGroup" select="@id" />
    <tr>
        <td colspan='6' width='100%'>
            <table width='100%' cellpadding='0' cellspacing='0' style='border: 1 solid #000000'>
                <tr>
                    <td width='80%' class='rowDet'><b><xsl:value-of select="Description" /></b></td>
                    <td class='rowDet' align='right'>
                        <xsl:if test="count(Object[ @dynamic='true' ]) &gt; 0">
                            <xsl:element name="asp:imageButton">
                                <xsl:attribute name='id'>reloadGroup_<xsl:value-of select='@id' /></xsl:attribute>
                                <xsl:attribute name='runat'>server</xsl:attribute>
                                <xsl:attribute name='imageurl'>images/reloadGroup.gif</xsl:attribute>
                                <xsl:attribute name='alt'>Reload <xsl:value-of select="Description" /></xsl:attribute>
                            </xsl:element>
                        </xsl:if>#160;
                        <xsl:if test="@allowadd[ .='true']">
                            <xsl:element name="asp:imageButton">
                                <xsl:attribute name='id'>lia_<xsl:value-of select='@id' /></xsl:attribute>
                                <xsl:attribute name='runat'>server</xsl:attribute>
                                <xsl:attribute name='src'>images/add.gif</xsl:attribute>
                                <xsl:attribute name='alt'>Add <xsl:value-of select="Description" /></xsl:attribute>
                            </xsl:element>
                        </xsl:if>#160;
                        <xsl:if test="@allowdelete[ .='true']">
                            <xsl:element name="asp:imageButton">
                                <xsl:attribute name='id'>lid_<xsl:value-of select='@id' /></xsl:attribute>
                                <xsl:attribute name='runat'>server</xsl:attribute>
                                <xsl:attribute name='src'>images/delete.gif</xsl:attribute>
                                <xsl:attribute name='alt'>Delete <xsl:value-of select="Description" /></xsl:attribute>
                            </xsl:element>
                        </xsl:if>
                    </td>
                </tr>

                <tr>
                    <td colspan='2' width='100%'>
                        <table cellspacing='1' cellpadding='3'>
                            <tr>
                                <xsl:if test="@count &gt; 0">

                                    <td></td>
                                    <xsl:for-each select="Object">
                                    <xsl:sort select="@index" data-type="number" />
                                        <xsl:if test="(string(Attributes/Attribute[ @name='visible']) = '') or (Attributes/Attribute[ @name='visible'] != 'False')">
                                            <td class='rowdet'>
                                                <xsl:attribute name='align'>center</xsl:attribute>
                                                <b><xsl:value-of select="Description" disable-output-escaping="yes" /></b>
                                            </td>
                                        </xsl:if>
                                    </xsl:for-each>
                                    <td></td>
                                </xsl:if>
                                <xsl:if test="@count = 0">
                                    <td>( No items found )</td>
                                </xsl:if>
                            </tr>

                            <xsl:if test="@count &gt; 0">

                                <xsl:variable name="obj" select="Object[ position()=1 ]/@name" />
                                <xsl:for-each select="Object[ @name=$obj ]/Value/@instance">
                                    <xsl:variable name="line" select="." />
                                    <tr>

                                        <xsl:choose>
                                                <xsl:when test="//ObjectGroup[@id=$tmpGroup][@allowadd='true']">
                                                    <td>
                                                        <xsl:element name="asp:CheckBox">
                                                            <xsl:attribute name='id'>__linecheck_<xsl:value-of select='$tmpGroup' />_<xsl:value-of select='$line' /></xsl:attribute>
                                                            <xsl:attribute name='runat'>server</xsl:attribute>
                                                        </xsl:element>
                                                    </td>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <td></td>
                                                </xsl:otherwise>
                                        </xsl:choose>


                                        <xsl:for-each select="//ObjectGroup[@id=$tmpGroup]/Object">
                                        <xsl:sort select="@index" data-type="number" />
                                        <xsl:variable name="name" select="concat('li_',concat($tmpGroup,concat('_',c oncat($line,concat('_',@name)))))" />
                                        <xsl:choose>
                                        <xsl:when test="(string(Attributes/Attribute[ @name='visible']) = '') or (Attributes/Attribute[ @name='visible'] != 'False')">
                                        <td>
                                            <xsl:call-template name="CreateLineItemObject">
                                                <xsl:with-param name="Object" select="." />
                                                <xsl:with-param name="name" select="$name" />
                                                <xsl:with-param name="line" select="$line" />
                                                <xsl:with-param name="tmpGroup" select="$tmpGroup" />
                                            </xsl:call-template>
                                        </td>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:call-template name="ReferenceLabel">
                                                <xsl:with-param name="Name" select="$name" />
                                                <xsl:with-param name="Attributes" select="Attributes" />
                                                <xsl:with-param name="Value" select="Value[ @instance=$line ]" />
                                            </xsl:call-template>
                                        </xsl:otherwise>
                                        </xsl:choose>
                                        </xsl:for-each>
                                    </tr>
                                </xsl:for-each>
                            </xsl:if>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    </xsl:for-each>

    <!--
        Now dump in the ungrouped invisible objects, if any.
        Invisible objects will always be output as labels, cause we're
        simply after an Object Name / Object Value pairing.
    -->
    <tr>
        <td colspan="6">
            <xsl:for-each select="Activity/ObjectGroup[@type='default']/Object[ ./Attributes/Attribute[ @name='visible' ] = 'False' ]">
                <xsl:call-template name="ReferenceLabel">
                    <xsl:with-param name="Name" select="@name" />
                    <xsl:with-param name="Attributes" select="Attributes" />
                    <xsl:with-param name="Value" select="Value" />
                </xsl:call-template>
            </xsl:for-each>
        </td>
    </tr>

    <xsl:variable name="cTrigger" select="count(Activity/ObjectGroup[@type='trigger']/Object)" />

    <xsl:if test="$cTrigger='1'">
        <xsl:for-each select="Activity/ObjectGroup[@type='trigger']/Object">
        <tr>

            <td width='30%' align='right' class='rowTrg'>
                <xsl:value-of select="Description" disable-output-escaping="yes" />#160;
            </td>
            <td colspan="4">
                <xsl:element name="asp:CheckBox">
                    <xsl:attribute name='id'><xsl:value-of select='@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:if test="Value[. = 'on']">
                        <xsl:attribute name='Checked'>True</xsl:attribute>
                    </xsl:if>
                </xsl:element>
            </td>
            <td>
            </td>
        </tr>
        </xsl:for-each>
    </xsl:if>

    <xsl:if test="$cTrigger &gt; '1'">
        <xsl:for-each select="Activity/ObjectGroup[@type='trigger']/Object">
        <tr>

            <td width='30%' align='right' class='rowTrg'>
                <xsl:value-of select="Description" disable-output-escaping="yes" />#160;
            </td>
            <td colspan="4">
                <xsl:element name="asp:RadioButton">
                    <xsl:attribute name='id'><xsl:value-of select='@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:attribute name='GroupName'>triggers</xsl:attribute>
 &nbs

ismailc December 24th, 2007 09:35 AM

Please anyone have a look as i have no experience in xslt, i'm just trying to incorporate a workaround into the xslt file!

Regards


joefawcett December 24th, 2007 12:02 PM

It's very difficult to work out what you want. Can't you show the XML that you have and what output you require?

--

Joe (Microsoft MVP - XML)

ismailc December 24th, 2007 12:40 PM

Hi,

In my previous mail the workaround html is like a replacement for the tooltip 'alt', the entire xslt file + work around is in the previous post.

The part it affects: but it moans about the node:
             <xsl:if test="$nextNode/Tooltip != ''">
                #160;
                <xsl:element name="asp:image">
                    <xsl:attribute name='id'>ttip_<xsl:value-of select='$nextNode/@name' /></xsl:attribute>
                    <xsl:attribute name='runat'>server</xsl:attribute>
                    <xsl:attribute name='imageurl'>images/tooltip.gif</xsl:attribute>
                    <xsl:attribute name='alt'><xsl:value-of select="$nextNode/Tooltip" /></xsl:attribute>
                </xsl:element>


I tried the following (works in html):
adding the script on top:
<style type='text/css' media='all'>
@import 'tooltip/css/global.css';
</style>
<script src='tooltip/js/jquery.js' type='text/javascript'></script>
<script src='tooltip/js/jtip.js' type='text/javascript'></script>

<xsl:if test="Tooltip != ''">
 <xsl:element name="asp:image">
 <xsl:attribute name='id'>one

 </xsl:attribute>


 <a>
  <xsl:attribute name='href'>ajax.htm</xsl:attribute>
  <xsl:attribute name='class'>jTip</xsl:attribute>

   ?</a>



</xsl:element>

</xsl:if>


Please have a look regards,!



All times are GMT -4. The time now is 10:23 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.