Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / February 2008

Tip: Looking for answers? Try searching our database.

does infopath xsl support variable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 26 Feb 2008 14:53 GMT
I manually edit xsl infopath generated , and try to add an variable,
like below.

<xsl:variable name ="tmpDay" select ="/tns:AddTpr/tns:entity/
tns:ActivityDayCollection/tns:ActivityDay/tns:Day" />

then I open the design the xsf file. Then the message shows up like
below.

A view in the form template contains a structure that InfoPath does
not support.

Structure details:
<xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
name="tmpDay" select="/tns:AddTpr/tns:entity/tns:ActivityDayCollection/
tns:ActivityDay/tns:Day"/>

Can anyone tell why?
Thanks
Gavin McKay - 26 Feb 2008 22:24 GMT
Hello,

I think Infopath is complaining because xsl:variable is not part of the
Infopath schema.  When the designer opens your form it validates the view Xsl
and that is probably why it is failing.

Why do you need to add an Xsl variable?  Are you trying to store this data
for later use?  If you are then I would suggest either use .NET code-behind
for your Infopath form, or create a data element in your data source to store
the information.

Gavin.

> I manually edit xsl infopath generated , and try to add an variable,
> like below.
[quoted text clipped - 15 lines]
> Can anyone tell why?
> Thanks
Fred - 27 Feb 2008 06:32 GMT
variable is very important in xslt, actually variable is so important
that if there is such thing in a language, that is not and language at
all.
Infopath is built on top of XSLT, I am sure infopath support
<xsl:variable> element, one example is to use variable is here.
http://www.infopathdev.com/files/folders/examples/entry272.aspx.

C# of course is good, but infopath is heavily based on xslt. But the
support of variable seems different from the normal xslt engine. My
style sheet contains variable , I can use it generate output in msxml
and .net XslTransform class, but the not by infopath.

Thanks
Fred

On Feb 26, 5:24 pm, Gavin McKay <GavinMc...@discussions.microsoft.com>
wrote:
> Hello,
>
[quoted text clipped - 28 lines]
> > Can anyone tell why?
> > Thanks
Fred - 29 Feb 2008 15:04 GMT
My problem has not been solved yet. The reason that I want use
xsl:variable is that I need to create a cross tab table. Without
infopath , I have a solution, there are two file, one is xml, one is
xsl to transform the xml into html. This xsl has been tested to able
to do the transformation.

xml is about a activitylist
<?xml version="1.0" encoding="utf-8" ?>
<ActivityList>
    <Item>
        <Day>1</Day>
        <Type>Meal</Type>
        <Name>Breakfast</Name>
        <Note></Note>
    </Item>
    <Item>
        <Day>1</Day>
        <Type>Meal</Type>
        <Name>Dinner</Name>
        <Note>lots of stuff</Note>
    </Item>
    <Item>
        <Day>1</Day>
        <Type>Tour</Type>
        <Name>Great wall</Name>
        <Note></Note>
    </Item>
    <Item>
        <Day>2</Day>
        <Type>Meal</Type>
        <Name>Breakfast</Name>
        <Note></Note>
    </Item>
    <Item>
        <Day>2</Day>
        <Type>Airport</Type>
        <Name>Transfer to hotel</Name>
        <Note></Note>
    </Item>
    <Item>
        <Day>3</Day>
        <Type>Airport</Type>
        <Name>Transfer to airport</Name>
        <Note></Note>
    </Item>
    <Item>
        <Day>3</Day>
        <Type>Meeting</Type>
        <Name>Face to face meeting</Name>
        <Note></Note>
    </Item>
</ActivityList>

the xsl is transform the day into column, type to row, and name to
data.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
   xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-
prefixes="msxsl"

   <xsl:output method="html" indent="yes"/>

    <xsl:template match="/">
        <xsl:variable name="distinctDayList" select="/ActivityList/
Item[not(Day=preceding-sibling::Item/Day)]/Day"></xsl:variable>
        <xsl:variable name ="distinctTypeList" select="/ActivityList/
Item[not(Type=preceding-sibling::Item/Type)]/Type"></xsl:variable>
        <html>
            <header>
                <style type="text/css">
                    table, td, th
                    {
                    border:solid 1px black
                    }
                    table
                    {
                    border-collapse:collapse;
                    }
                </style>
            </header>
            <body>
                <h1>Cross tab demo</h1>
                <table>
                    <tr>
                        <!--build day row-->
                        <th>Type</th>
                        <xsl:for-each select="$distinctDayList">
                            <xsl:sort select="Day"/>
                            <th>
                                <xsl:value-of select="."/>
                            </th>
                        </xsl:for-each>
                    </tr>
                    <xsl:for-each select="$distinctTypeList">
                        <xsl:sort select="Type" data-type="text"/>
                        <tr>
                            <td>
                                <xsl:value-of select="."/>
                            </td>
                            <xsl:variable name="currentType" select="."></xsl:variable>
                            <xsl:for-each select="$distinctDayList" >
                                <td>
                                    <xsl:for-each select="/ActivityList/Item[Day=current() and
Type=$currentType]">
                                        <xsl:value-of select="Name"/>
                                        <xsl:if test="position()!=last()">
                                            ,
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </xsl:for-each>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

Infopath designer can not achieve that , so I need to open the
view1.xsl in text editor. and make the following change

<!-- leave out lots infopath tag above -->
    <xsl:template match="/">
        <xsl:variable name="distinctDayList" select="/ActivityList/
Item[not(Day=preceding-sibling::Item/Day)]/Day"></xsl:variable>
        <xsl:variable name ="distinctTypeList" select="/ActivityList/
Item[not(Type=preceding-sibling::Item/Type)]/Type"></xsl:variable>
<html>
            <head>
<!-- leave out lots infopath tag here -->
</head>
    <body style="COLOR: #000000; BACKGROUND-COLOR: #ffffff">
                <h1>Cross tab demo</h1>
                <table>
                    <tr>
                        <!--build day row-->
                        <th>Type</th>
                        <xsl:for-each select="$distinctDayList">
                            <xsl:sort select="Day"/>
                            <th>
                                <xsl:value-of select="."/>
                            </th>
                        </xsl:for-each>
                    </tr>
                    <xsl:for-each select="$distinctTypeList">
                        <xsl:sort select="Type" data-type="text"/>
                        <tr>
                            <td>
                                <xsl:value-of select="."/>
                            </td>
                            <xsl:variable name="currentType" select="."></xsl:variable>
                            <xsl:for-each select="$distinctDayList" >
                                <td>
                                    <xsl:for-each select="/ActivityList/Item[Day=current() and
Type=$currentType]">
                                        <xsl:value-of select="Name"/>
                                        <xsl:if test="position()!=last()">
                                            ,
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </xsl:for-each>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>

When I design xsf , I got this message,
A view in the form template contains a structure that InfoPath does
not support.

Structure details:
<xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
name="distinctTypeList" select="/ActivityList/Item[not(Type=preceding-
sibling::Item/Type)]/Type"></xsl:variable>

The variable is at the top template, so scope should be accessible in
inner level. First I think is the xpath expression seems to be not
friendly to infopath. So I change it to a very simple expression, but
it still complained the same thing, so I think variable is the
problem. Inofpath is xsl based solution, why it does not support this
valid xsl? Does infopath team or somebody has an answer to this?

Thanks
Fred

> variable is very important in xslt, actually variable is so important
> that if there is such thing in a language, that is not and language at
[quoted text clipped - 45 lines]
> > > Can anyone tell why?
> > > Thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.