xsl transforms and infopath views - InfoPath Dev
in

InfoPath Dev

xsl transforms and infopath views

Last post 06-12-2009 12:18 PM by Patrick Halstead. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-11-2009 09:31 AM

    xsl transforms and infopath views

    I have an xsl file that transforms infopath xml form data into semicolon-delimited rows in html.

    Is there a way to import/link this xsl file and create a view in the infopath form that would render the form data in a similiar fashion?  The rendered html looks like this:

    123456;PC.01.02.07.EP1;2;2;THIS IS A TEST
    123456;PC.01.02.07.EP3+4;0;1;THIS IS A TEST

     

    Here is the xsl:

    <?xml version="1.0" encoding="ISO-8859-1"?>

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

    <xsl:template match="/">
      <html>
      <body>


        <xsl:for-each select="encounter/response">

          <xsl:value-of select="/encounter/@AptIEN"/>;<xsl:value-of select="standard"/>;<xsl:value-of select="numerator"/>;<xsl:value-of select="denominator"/>;<xsl:value-of select="comment"/>

          <br/>

        </xsl:for-each>

      </body>
      </html>
    </xsl:template>

    </xsl:stylesheet>

  • 06-11-2009 01:39 PM In reply to

    Re: xsl transforms and infopath views

    Hi Christian,

    In the InfoPath Designer, first, create a blank view. Then, save the source files by clicking File->Save Source Files. Close the Designer. Go to the folder where you saved the source files. Find the view*.xsl file with the highest number (if you only have 2 views, it will probably be view2.xsl). Open this in Notepad. Manually edit. Save. Right click on manifest.xsf and choose Design. Switch to the new view and click Preview.

    Word of caution: manually modifying the XSL is a very advanced technique. It's easy to break the XSL and prevent InfoPath from opening. Always back it up before proceeding.

    Good luck!

    Patrick Halstead
    Project Manager at Qdabra
  • 06-12-2009 08:51 AM In reply to

    Re: xsl transforms and infopath views

    Patrick,

    Thanks for your suggestion.  I added a blank view, extracted the files, and opened the new view in notepad.  The xsl autogenerated by InfoPath for the blank view is at the bottom of this post.  You're right about InfoPath being picky about tweaking the code.

    Theoretically (if InfoPath xsl is not proprietary) , all I should need to add to the autogenerated code are these four lines:

    <xsl:for-each select="encounter/response">
        <xsl:value-of select="/encounter/@AptIEN"/>;<xsl:value-of select="standard"/>;<xsl:value-of select="numerator"/>;<xsl:value-of select="denominator"/>;<xsl:value-of select="comment"/>
         <br/>
    </xsl:for-each>

    I tried adding these lines at the end of the autogenerated code before these closing tags: </body></html></xsl:template></xsl:stylesheet>

    I also tried this variation of the closing tags: </head><body><div/></body></html></xsl:template></xsl:stylesheet>

    In both cases the resulting error message is:

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

    Structure details:
    <xsl:value-of xmlns:xsl="
    http://www.w3.org/1999/XSL/Transform" select="/encounter/@AptIEN"/>

    Any thoughts?  The schema is referenced in the manifest, so I shouldn't need to (in fact I don't think I can) include the schema in the xsl, right?

    Thanks again for your help.  It's frustrating that I can transform the xml externally, but not within the InfoPath form.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    AUTOGENERATED XSL

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"></xsl:output>
    <xsl:template match="/"><html xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"><head>
    <meta http-equiv="Content-Type" content="text/html"/>
    <style controlStyle="controlStyle" xmlns:msxsl="urn:schemas-microsoft-com:xslt"  xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"  xmlns:x="urn:schemas-microsoft-com:office:excel"  xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension"  xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument"  xmlns:xdSolution="http://schemas.microsoft.com/office/infopath/2003/xslt/solution"  xmlns:xdFormatting="http://schemas.microsoft.com/office/infopath/2003/xslt/formatting"  xmlns:xdImage="http://schemas.microsoft.com/office/infopath/2003/xslt/xImage"  xmlns:xdUtil="http://schemas.microsoft.com/office/infopath/2003/xslt/Util"  xmlns:xdMath="http://schemas.microsoft.com/office/infopath/2003/xslt/Math"  xmlns:xdDate="http://schemas.microsoft.com/office/infopath/2003/xslt/Date"  xmlns:sig="http://www.w3.org/2000/09/xmldsig#"  xmlns:xdSignatureProperties="http://schemas.microsoft.com/office/infopath/2003/SignatureProperties" >
    @media Screen   
    {
    BODY {
     BACKGROUND-POSITION: 21px 0px; MARGIN-LEFT: 21px
    }
        }
    BODY {
     LAYOUT-GRID: none none none; COLOR: windowtext; BACKGROUND-COLOR: window
    }
    .xdListItem {
     DISPLAY: inline-block; VERTICAL-ALIGN: text-top; WIDTH: 100%
    }
    .xdListBox {
     MARGIN: 1px
    }
    .xdComboBox {
     MARGIN: 1px
    }
    .xdInlinePicture {
     MARGIN: 1px; BEHAVIOR: url(#default#urn::xdPicture) url(#default#DataBindingUI)
    }
    .xdLinkedPicture {
     MARGIN: 1px; BEHAVIOR: url(#default#urn::xdPicture) url(#default#urn::controls/Binder) url(#default#DataBindingUI)
    }
    .xdSection {
     BORDER-RIGHT: #ffffff 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #ffffff 1pt solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 1px; MARGIN: 6px 0px; BORDER-LEFT: #ffffff 1pt solid; PADDING-TOP: 1px; BORDER-BOTTOM: #ffffff 1pt solid
    }
    .xdRepeatingSection {
     BORDER-RIGHT: #ffffff 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #ffffff 1pt solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 1px; MARGIN: 6px 0px; BORDER-LEFT: #ffffff 1pt solid; PADDING-TOP: 1px; BORDER-BOTTOM: #ffffff 1pt solid
    }
    .xdDataBindingUI {
     BEHAVIOR: url(#default#DataBindingUI)
    }
    .xdXButton {
     BEHAVIOR: url(#default#DataBindingUI); FONT-FAMILY: Verdana
    }
    .xdHyperlink {
     BORDER-RIGHT: #dcdcdc 1pt dotted; BORDER-TOP: #dcdcdc 1pt dotted; DISPLAY: inline-block; BORDER-LEFT: #dcdcdc 1pt dotted; BORDER-BOTTOM: #dcdcdc 1pt dotted
    }
    .xdExpressionBox {
     BORDER-RIGHT: #dcdcdc 1pt dotted; PADDING-RIGHT: 1px; BORDER-TOP: #dcdcdc 1pt dotted; DISPLAY: inline-block; PADDING-LEFT: 1px; OVERFLOW-X: hidden; PADDING-BOTTOM: 1px; MARGIN: 1px; BORDER-LEFT: #dcdcdc 1pt dotted; PADDING-TOP: 1px; BORDER-BOTTOM: #dcdcdc 1pt dotted; TEXT-OVERFLOW: ellipsis; WORD-WRAP: break-word
    }
    .xdRepeatingTable {
     BEHAVIOR: url(#default#urn::tables/NDTable) url(#default#RepeatingItemUI) url(#default#DataBindingUI); BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; BORDER-BOTTOM-STYLE: none
    }
    TABLE.xdFormLayout TD {
     BEHAVIOR: url(#default#LayoutText)
    }
    .xdRepeating {
     DISPLAY: inline-block; BEHAVIOR: url(#default#RepeatingItemUI) url(#default#DataBindingUI)
    }
    .xdBehavior_Formatting {
     BEHAVIOR: url(#default#Formatting) url(#default#DataBindingUI)
    }
    .xdBehavior_GTFormatting {
     BEHAVIOR: url(#default#Formatting) url(#default#DataBindingUI)
    }
    .xdBehavior_FormattingNoBUI {
     BEHAVIOR: url(#default#Formatting)
    }
    .xdBehavior_GTFormattingNoBUI {
     BEHAVIOR: url(#default#Formatting)  url(#default#GhostedText)
    }
    .xdBehavior_Boolean {
     BEHAVIOR: url(#default#BooleanHelper) url(#default#DataBindingUI)
    }
    .xdBehavior_Select {
     BEHAVIOR: url(#default#SelectHelper) url(#default#DataBindingUI/Select)
    }
    .xdActiveX {
     MARGIN: 1px; BEHAVIOR: url(#default#DataBindingUI)
    }
    .xdScrollableRegion {
     BEHAVIOR: url(#default#RepeatingItemUI)
    }
    .xdFileAttachment {
     DISPLAY: inline-block; MARGIN: 1px; BEHAVIOR: url(#default#DesignerFileAttachmentUI) url(#default#DataBindingUI)
    }

    @media Print   
    {
    .xdPageBreak {
     DISPLAY: none
    }

    }

    @media Screen   
    {
    .xdPageBreak {
     BORDER-TOP: #aaaaaa 1pt dashed; WIDTH: 100%
    }
        }
    BODY {
     MARGIN-RIGHT: 21px
    }
    .xdTextBoxRTL {
     BORDER-RIGHT: #dcdcdc 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #dcdcdc 1pt solid; DISPLAY: inline-block; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; MARGIN: 1px; BEHAVIOR: url(#default#DataBindingUI); OVERFLOW: hidden; BORDER-LEFT: #dcdcdc 1pt solid; COLOR: windowtext; PADDING-TOP: 1px; BORDER-BOTTOM: #dcdcdc 1pt solid; WHITE-SPACE: nowrap; TEXT-OVERFLOW: ellipsis; BACKGROUND-COLOR: window; TEXT-ALIGN: right
    }
    .xdRichTextBoxRTL {
     BORDER-RIGHT: #dcdcdc 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #dcdcdc 1pt solid; DISPLAY: inline-block; PADDING-LEFT: 1px; FONT-WEIGHT: normal; OVERFLOW-X: hidden; PADDING-BOTTOM: 1px; MARGIN: 1px; BEHAVIOR: url(#default#DataBindingUI); VERTICAL-ALIGN: baseline; BORDER-LEFT: #dcdcdc 1pt solid; COLOR: windowtext; PADDING-TOP: 1px; BORDER-BOTTOM: #dcdcdc 1pt solid; FONT-STYLE: normal; TEXT-OVERFLOW: ellipsis; BACKGROUND-COLOR: window; TEXT-ALIGN: right; TEXT-DECORATION: none; WORD-WRAP: break-word
    }
    .xdDTTextRTL {
     PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 22px; OVERFLOW: hidden; WIDTH: 100%; PADDING-TOP: 0px; WHITE-SPACE: nowrap; HEIGHT: 100%
    }
    .xdDTButtonRTL {
     BEHAVIOR: url(#default#DTPicker); WIDTH: 20px; MARGIN-RIGHT: -21px; HEIGHT: 18px
    }
    .xdTextBox {
     BORDER-RIGHT: #dcdcdc 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #dcdcdc 1pt solid; DISPLAY: inline-block; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; MARGIN: 1px; BEHAVIOR: url(#default#DataBindingUI); OVERFLOW: hidden; BORDER-LEFT: #dcdcdc 1pt solid; COLOR: windowtext; PADDING-TOP: 1px; BORDER-BOTTOM: #dcdcdc 1pt solid; WHITE-SPACE: nowrap; TEXT-OVERFLOW: ellipsis; BACKGROUND-COLOR: window; TEXT-ALIGN: left
    }
    .xdRichTextBox {
     BORDER-RIGHT: #dcdcdc 1pt solid; PADDING-RIGHT: 1px; BORDER-TOP: #dcdcdc 1pt solid; DISPLAY: inline-block; PADDING-LEFT: 1px; FONT-WEIGHT: normal; OVERFLOW-X: hidden; PADDING-BOTTOM: 1px; MARGIN: 1px; BEHAVIOR: url(#default#DataBindingUI); VERTICAL-ALIGN: baseline; BORDER-LEFT: #dcdcdc 1pt solid; COLOR: windowtext; PADDING-TOP: 1px; BORDER-BOTTOM: #dcdcdc 1pt solid; FONT-STYLE: normal; TEXT-OVERFLOW: ellipsis; BACKGROUND-COLOR: window; TEXT-ALIGN: left; TEXT-DECORATION: none; WORD-WRAP: break-word
    }
    .xdDTPicker {
     BORDER-RIGHT: #dcdcdc 1pt solid; BORDER-TOP: #dcdcdc 1pt solid; DISPLAY: inline; MARGIN: 1px 1px 2px; BEHAVIOR: url(#default#DataBindingUI); OVERFLOW: hidden; BORDER-LEFT: #dcdcdc 1pt solid; COLOR: windowtext; BORDER-BOTTOM: #dcdcdc 1pt solid; BACKGROUND-COLOR: window
    }
    .xdDTText {
     PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; OVERFLOW: hidden; WIDTH: 100%; MARGIN-RIGHT: 22px; PADDING-TOP: 0px; WHITE-SPACE: nowrap; HEIGHT: 100%
    }
    .xdDTButton {
     BEHAVIOR: url(#default#DTPicker); MARGIN-LEFT: -21px; WIDTH: 20px; HEIGHT: 18px
    }
    .xdRepeatingTable TD {
     VERTICAL-ALIGN: top
    }
    </style>
    <style tableEditor="TableStyleRulesID" xmlns:msxsl="urn:schemas-microsoft-com:xslt"  xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"  xmlns:x="urn:schemas-microsoft-com:office:excel"  xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension"  xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument"  xmlns:xdSolution="http://schemas.microsoft.com/office/infopath/2003/xslt/solution"  xmlns:xdFormatting="http://schemas.microsoft.com/office/infopath/2003/xslt/formatting"  xmlns:xdImage="http://schemas.microsoft.com/office/infopath/2003/xslt/xImage"  xmlns:xdUtil="http://schemas.microsoft.com/office/infopath/2003/xslt/Util"  xmlns:xdMath="http://schemas.microsoft.com/office/infopath/2003/xslt/Math"  xmlns:xdDate="http://schemas.microsoft.com/office/infopath/2003/xslt/Date"  xmlns:sig="http://www.w3.org/2000/09/xmldsig#"  xmlns:xdSignatureProperties="http://schemas.microsoft.com/office/infopath/2003/SignatureProperties" >TABLE.xdLayout TD {
     BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none
    }
    TABLE.msoUcTable TD {
     BORDER-RIGHT: 1pt solid; BORDER-TOP: 1pt solid; BORDER-LEFT: 1pt solid; BORDER-BOTTOM: 1pt solid
    }
    TABLE {
     BEHAVIOR: url (#default#urn::tables/NDTable)
    }
    </style>
    <style languageStyle="languageStyle" xmlns:msxsl="urn:schemas-microsoft-com:xslt"  xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"  xmlns:x="urn:schemas-microsoft-com:office:excel"  xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension"  xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument"  xmlns:xdSolution="http://schemas.microsoft.com/office/infopath/2003/xslt/solution"  xmlns:xdFormatting="http://schemas.microsoft.com/office/infopath/2003/xslt/formatting"  xmlns:xdImage="http://schemas.microsoft.com/office/infopath/2003/xslt/xImage"  xmlns:xdUtil="http://schemas.microsoft.com/office/infopath/2003/xslt/Util"  xmlns:xdMath="http://schemas.microsoft.com/office/infopath/2003/xslt/Math"  xmlns:xdDate="http://schemas.microsoft.com/office/infopath/2003/xslt/Date"  xmlns:sig="http://www.w3.org/2000/09/xmldsig#"  xmlns:xdSignatureProperties="http://schemas.microsoft.com/office/infopath/2003/SignatureProperties" >BODY {
     FONT-SIZE: 10pt; FONT-FAMILY: Verdana
    }
    TABLE {
     FONT-SIZE: 10pt; FONT-FAMILY: Verdana
    }
    SELECT {
     FONT-SIZE: 10pt; FONT-FAMILY: Verdana
    }
    .optionalPlaceholder {
     PADDING-LEFT: 20px; FONT-WEIGHT: normal; FONT-SIZE: xx-small; BEHAVIOR: url(#default#xOptional); COLOR: #333333; FONT-STYLE: normal; FONT-FAMILY: Verdana; TEXT-DECORATION: none
    }
    .langFont {
     FONT-FAMILY: Verdana
    }
    .defaultInDocUI {
     FONT-SIZE: xx-small; FONT-FAMILY: Verdana
    }
    .optionalPlaceholder {
     PADDING-RIGHT: 20px
    }
    </style></head><body><div/></body></html></xsl:template></xsl:stylesheet>

  • 06-12-2009 12:18 PM In reply to

    Re: xsl transforms and infopath views

    There are a few special XSL tags for special InfoPath controls (like datepicker, etc.), but in general it is not proprietary except for a handful of special controls, that you don't need for this.

    My guess is that you are not referencing the XML correctly because the schema namespace is needed or something. Your external XSL may be ok because it isn't validating against a schema, it's just transforming. InfoPath gives you better support for XSL and XML here.

    Do this: In Designer, create a third view and drag the fields you want to display in the second view into that. Then, save as source and look at how InfoPath created the XSLT.

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.