Background Color:
 
Background Pattern:
Reset
Search

Forum

Please Log In

We want you to contribute! 

This forum is a moderated environment. 
We try to keep it neat and tidy. In order to access the forum content we would like you to either or register.

HomeHomeScryberScryberIssues and Defe...Issues and Defe...Data:if and page-refData:if and page-ref
Previous
 
Next
New Post
6/9/2015 8:25 PM
 

Dear all,

 we're thinking about licensing scryber for a couple of projects. We're very satisfied but have one big problem:

 We want to use Data:if in combination with page-ref so that the display of some pdf pages depend on values in our XML file:

 

   
     
       
     

   

         
              
       
         
       

     

   
     
 

 

To me it looks like the ForEach-loop is left after the first Page-Ref takes part. So when the first if is true, Report1 is displayed, but not Report2 (even if the if is true).

Can you help us?

 
New Post
6/9/2015 10:49 PM
 

Hi

Have to say I am having trouble replicating the issue.

I have put this together to try and match your input below.

<pdf:Document xmlns:pdf="Scryber.Components, Scryber.Components, Version=0.9.0.0, Culture=neutral, PublicKeyToken=872cbeb81db952fe"

              xmlns:data="Scryber.Data, Scryber.Components, Version=0.9.0.0, Culture=neutral, PublicKeyToken=872cbeb81db952fe"

              xmlns:style="Scryber.Styles, Scryber.Styles, Version=0.9.0.0, Culture=neutral, PublicKeyToken=872cbeb81db952fe"

              auto-bind="true" >

  <Viewer fit-window="true" page-display="Thumbnails" page-layout="SinglePage"/>

  <Items>

    <pdf:Xml-Item key="elements">

      <ReportElements xmlns="JustATest" >

        <ReportElement name="Report 1" ischecked="true" />

        <ReportElement name="Report 2" ischecked="true" />

      </ReportElements>

    </pdf:Xml-Item>

  </Items>

  <Pages>

 

    <pdf:Page id="First" >

      <Content>First Content</Content>

    </pdf:Page>

 

    <data:XMLDataSource id="TryThis" xml-node-data="{item:elements}" >

      <Namespaces>

        <data:Xmlns prefix="t" namespace="JustATest"/>

      </Namespaces>

    </data:XMLDataSource>

 

    <data:ForEach select="/t:ReportElements/t:ReportElement" datasource-id="TryThis" >

      <Template>

        

        <data:If test="@name='Report 1'" >

          <Template>

            <data:If test="@ischecked='true'" >

              <Template>

                <pdf:Page id="Report1Checked" >

                  <Content>

                    Report 1 is checked = true

                  </Content>

                </pdf:Page>

              </Template>

            </data:If>

          </Template>

        </data:If>

        

        <data:If test="@name='Report 2'" >

          <Template>

            <data:If test="@ischecked='true'" >

              <Template>

                <pdf:Page id="Report1Checked" >

                  <Content>

                    Report 2 is checked = true

                  </Content>

                </pdf:Page>

              </Template>

            </data:If>

          </Template>

        </data:If>

        

      </Template>

      

    </data:ForEach>

    

    <pdf:Page id="Last">

      <Content>

        This is the last page

      </Content>

    </pdf:Page>

  </Pages>

</pdf:Document>


Now I am using the very latest version - 0.9 (which allows me to declare the Xml in the document.

However I am getting 4 pages, and if I switch data values it seems to act predictably.

 

You could try moving your if test to the higher level, and then using a Choose/When for the report name as the inner check.

 <data:If test="@ischecked = 'true'" >

          <Template>

 

            <data:Choose>

              <data:When test="@name='Report 1'" >

                <Template>

                  <pdf:Page id="Report1Checked" >

                    <Content>

                      Report 1 is checked = true

                    </Content>

                  </pdf:Page>

                </Template>

              </data:When>

              <data:When test="@name='Report 2'" >

                <Template>

                  <pdf:Page id="Report2Checked" >

                    <Content>

                      Report 2 is checked = true

                    </Content>

                  </pdf:Page>

                </Template>

              </data:When>

            </data:Choose>

          </Template>

        </data:If>


Hope this helps

 
New Post
6/10/2015 7:58 AM
 

Hi,

 thank you for the quick reply.

There is a slightly difference between my and your code: I'm trying to reference another page (ppfx-file) so I'm using pdf:Page-Ref while you are using just pdf:Page. I don't have any problem with pdf:Page, but with pdf:Page-Ref. Referencing another ppfx file seems to leave the ForEach-loop.

 
New Post
6/10/2015 8:47 AM
 

I did some further investigations:

 The problem was that the pdf:Page-Ref tag was placed inside a Content tag. This mustn't be.

Now it works perfectly. Thanks. :-)

 
New Post
6/10/2015 9:53 AM
 

Great. I am glad it is working for you!

Richard

 
Previous
 
Next
HomeHomeScryberScryberIssues and Defe...Issues and Defe...Data:if and page-refData:if and page-ref