-
Hello, I really try hard to understand this by myself but I failed, also when I read the output often I don't understand what is written… My approach to use grid to laid out the space ended up being wrong so I moved over the table, but I am doing this wrong, thus I have duplicated content or simply no output… 🤦♂️ The scope is pretty trivial, just having each cell populate with the titles and the items As usual the <data>
<animals title="MAMMALS:">
<item new="true">Baby Dog</item>
<item new="true">Baby Cat</item>
<item new="true">Baby Horse</item>
<item new="false">Mommy Dog</item>
<item new="false">Mommy Cat</item>
<item new="false">Mommy Horse</item>
<item new="false">Daddy Dog</item>
<item new="false">Daddy Cat</item>
<item new="false">Daddy Horse</item>
</animals>
<animals title="BIRDS:">
<item new="true">Baby Eagle</item>
<item new="true">Baby Flamenco</item>
<item new="true">Baby Vultur</item>
<item new="false">Mommy Eagle</item>
<item new="false">Mommy Flamenco</item>
<item new="false">Mommy Vultur</item>
<item new="false">Daddy Eagle</item>
<item new="false">Daddy Flamenco</item>
<item new="false">Daddy Vultur</item>
</animals>
<animals title="FISHES:">
<item new="true">Baby Shark</item>
<item new="true">Baby Betta</item>
<item new="true">Baby Tuna</item>
<item new="false">Mommy Shark</item>
<item new="false">Mommy Betta</item>
<item new="false">Mommy Tuna</item>
<item new="false">Daddy Shark</item>
<item new="false">Daddy Betta</item>
<item new="false">Daddy Tuna</item>
</animals>
<animals title="REPTILES:">
<item new="true">Baby Lizard</item>
<item new="true">Baby Turtle</item>
<item new="true">Baby Crocodile</item>
<item new="false">Mommy Lizard</item>
<item new="false">Mommy Turtle</item>
<item new="false">Mommy Crocodile</item>
<item new="false">Daddy Lizard</item>
<item new="false">Daddy Turtle</item>
<item new="false">Daddy Crocodile</item>
</animals>
<animals title="AMPHIBIANS:">
<item>Baby Frog</item>
<item new="false">Baby Toad</item>
<item new="false">Baby Salamander</item>
<item new="false">Mommy Frog</item>
<item new="false">Mommy Toad</item>
<item new="false">Mommy Salamander</item>
<item new="false">Daddy Frog</item>
<item new="false">Daddy Toad</item>
<item new="false">Daddy Salamander</item>
</animals>
<animals title="INSECTS:">
<item new="true">Baby Ladybug</item>
<item new="true">Baby Spider</item>
<item new="true">Baby Dragonfly</item>
<item new="false">Mommy Ladybug</item>
<item new="false">Mommy Spider</item>
<item new="false">Mommy Dragonfly</item>
<item new="false">Daddy Ladybug</item>
<item new="false">Daddy Spider</item>
<item new="false">Daddy Dragonfly</item>
</animals>
</data> The first attempt that creates duplicated entries <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en" >
<!-- Page size and structure -->
<SetGrid height="1cm" width="1cm" />
<Trace grid="yes" textformat="no" objects="yes"/>
<Pageformat width="210mm" height="290mm" />
<!-- Fonts definitions -->
<LoadFontfile name="CrimsonPro-Regular" filename="CrimsonPro-Regular.ttf" mode="harfbuzz"/>
<LoadFontfile name="CamingoCode-Bold" filename="CamingoCode-Bold.ttf" mode="harfbuzz" />
<DefineFontfamily fontsize="12" leading="14" name="para">
<Regular fontface="CrimsonPro-Regular" />
</DefineFontfamily>
<DefineFontfamily fontsize="12" leading="14" name="tito">
<Regular fontface="CamingoCode-Regular" />
<Bold fontface="CamingoCode-Bold" />
</DefineFontfamily>
<!-- Page Areas
Margins
Header
Footer
Body -->
<Pagetype name="page" test="true()">
<Margin left="1cm" right="1cm" top="1cm" bottom="3cm" />
<PositioningArea name="header">
<PositioningFrame width="19" height="1" row="1" column="1" />
</PositioningArea>
<PositioningArea name="body">
<PositioningFrame
width="19"
height="{sd:number-of-rows() -3}"
row="3"
column="1" />
</PositioningArea>
<PositioningArea name="footer">
<PositioningFrame width="19" height="1" row="{sd:number-of-rows()}" column="1" />
</PositioningArea>
</Pagetype>
<!-- Pages numbering -->
<!-- TitleBlock graphic definitions -->
<DefineGraphic name="ylwrounded">
filldraw box withcolor 0.8yellow ;
clip currentpicture to roundedsquare(box.width + 7mm, box.height, 3mm);
</DefineGraphic>
<DefineGraphic name="newrounded">
filldraw (0,0) -- (box.width,0) -- (box.width, box.height) --
(box.width, box.height) -- (-0.5cm, box.height ) -- cycle withcolor 0.7red ;
clip currentpicture to roundedsquare(box.width + 1cm, box.height, 3mm) shifted (-1cm,0mm);
</DefineGraphic>
<!-- ############## -->
<!-- Begins content -->
<!-- ############## -->
<!-- Loads all nodes -->
<Record element="data">
<ProcessNode select="animals" />
</Record>
<!-- Populates pages -->
<Record element="animals">
<PlaceObject area="header">
<Textblock>
<Paragraph>
<Value>HEADER </Value>
<Value select="sd:number-of-rows('header')" />
</Paragraph>
</Textblock>
</PlaceObject>
<PlaceObject area="body">
<Table padding="2mm" stretch="max">
<Columns>
<Column width="1*" />
<Column width="1*" />
</Columns>
<Tr>
<Td align="left">
<Paragraph>
<Value select="@title" />
</Paragraph>
<ForAll select="item">
<Paragraph>
<Value select="." />
</Paragraph>
</ForAll>
</Td>
<Td align="left">
<Paragraph>
<Value select="@title" />
</Paragraph>
<ForAll select="item">
<Paragraph>
<Value select="." />
</Paragraph>
</ForAll>
</Td>
</Tr>
</Table>
</PlaceObject>
<PlaceObject area="footer">
<Textblock>
<Paragraph>
<Value> FOOTER </Value>
<Value select="sd:number-of-rows('footer')" />
</Paragraph>
</Textblock>
</PlaceObject>
</Record>
</Layout> The last attempt that produce 0 page but at least the PDF file <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en" >
<!-- Page size and structure -->
<SetGrid height="1cm" width="1cm" />
<Trace grid="yes" textformat="no" objects="yes"/>
<Pageformat width="210mm" height="290mm" />
<!-- Fonts definitions -->
<LoadFontfile name="CrimsonPro-Regular" filename="CrimsonPro-Regular.ttf" mode="harfbuzz"/>
<LoadFontfile name="CamingoCode-Bold" filename="CamingoCode-Bold.ttf" mode="harfbuzz" />
<DefineFontfamily fontsize="12" leading="14" name="para">
<Regular fontface="CrimsonPro-Regular" />
</DefineFontfamily>
<DefineFontfamily fontsize="12" leading="14" name="tito">
<Regular fontface="CamingoCode-Regular" />
<Bold fontface="CamingoCode-Bold" />
</DefineFontfamily>
<!-- Page Areas
Margins
Header
Footer
Body -->
<Pagetype name="page" test="true()">
<Margin left="1cm" right="1cm" top="1cm" bottom="3cm" />
<PositioningArea name="header">
<PositioningFrame width="19" height="1" row="1" column="1" />
</PositioningArea>
<PositioningArea name="body">
<PositioningFrame
width="19"
height="{sd:number-of-rows() -3}"
row="3"
column="1" />
</PositioningArea>
<PositioningArea name="footer">
<PositioningFrame width="19" height="1" row="{sd:number-of-rows()}" column="1" />
</PositioningArea>
</Pagetype>
<!-- Pages numbering -->
<!-- TitleBlock graphic definitions -->
<DefineGraphic name="ylwrounded">
filldraw box withcolor 0.8yellow ;
clip currentpicture to roundedsquare(box.width + 7mm, box.height, 3mm);
</DefineGraphic>
<DefineGraphic name="newrounded">
filldraw (0,0) -- (box.width,0) -- (box.width, box.height) --
(box.width, box.height) -- (-0.5cm, box.height ) -- cycle withcolor 0.7red ;
clip currentpicture to roundedsquare(box.width + 1cm, box.height, 3mm) shifted (-1cm,0mm);
</DefineGraphic>
<!-- ############## -->
<!-- Begins content -->
<!-- ############## -->
<!-- Loads all nodes -->
<Record element="data">
<ProcessNode select="animals" />
</Record>
<!-- populates cell -->
<SetVariable variable="cell">
<Copy-of select="$cell" />
<Paragraph>
<Value select="@title" />
</Paragraph>
<ForAll select="item">
<Paragraph>
<Value select="." />
</Paragraph>
</ForAll>
</SetVariable>
<!-- Populates pages -->
<Record element="animals">
<PlaceObject area="header">
<Textblock>
<Paragraph>
<Value>HEADER</Value>
<Value select="sd:number-of-rows('header')" />
</Paragraph>
</Textblock>
</PlaceObject>
<PlaceObject area="body">
<Table padding="2mm" stretch="max">
<Columns>
<Column width="1*" />
<Column width="1*" />
</Columns>
<Tr>
<Td>
<Copy-of select="$cell"/>
</Td>
<Td>
<Copy-of select="$cell"/>
</Td>
</Tr>
<Tr>
<Td>
<Copy-of select="$cell"/>
</Td>
<Td>
<Copy-of select="$cell"/>
</Td>
</Tr>
</Table>
</PlaceObject>
<PlaceObject area="footer">
<Textblock>
<Paragraph>
<Value>FOOTER</Value>
<Value select="sd:number-of-rows('footer')" />
</Paragraph>
</Textblock>
</PlaceObject>
</Record>
</Layout> Thanks… 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The second layout first: There is an error in the logic: <SetVariable variable="cell">
<Copy-of select="$cell" />
<Paragraph>
<Value select="@title" />
</Paragraph>
<ForAll select="item">
<Paragraph>
<Value select="." />
</Paragraph>
</ForAll>
</SetVariable> is on the top level (not within a Now the first layout: with There are always several approaches to get what you need. One could be the following: <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<SetGrid nx="2" ny="3"/>
<Record element="data">
<ForAll select="animals">
<PlaceObject>
<Table>
<Tr>
<Td>
<Paragraph>
<Value select="@title" />
</Paragraph>
<Paragraph>
<ForAll select="item">
<Value select="." /><Br />
</ForAll>
</Paragraph>
</Td>
</Tr>
</Table>
</PlaceObject>
</ForAll>
</Record>
</Layout> or equivalent (with ProcessNode instead of ForAll): <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<SetGrid nx="2" ny="3"/>
<Record element="data">
<ProcessNode select="animals" />
</Record>
<Record element="animals">
<PlaceObject>
<Table>
<Tr>
<Td>
<Paragraph>
<Value select="@title" />
</Paragraph>
<Paragraph>
<ForAll select="item">
<Value select="." /><Br />
</ForAll>
</Paragraph>
</Td>
</Tr>
</Table>
</PlaceObject>
</Record>
</Layout> This defines a 2x3 grid page and places a table without giving a row and a column. The speedata Publisher looks for the next free grid cell and places the table wherever it thinks it is best (from left to right, from top to the bottom). This is why the 6 grid cells are used without addressing them explicitly. Edit: you can play with debugging by setting |
Beta Was this translation helpful? Give feedback.
-
I can't provide any further reading besides the manual, the examples repository or the qa directory from the repository. For more complex layout you can use tables within tables or adjust some spacing with columns or transparent table rules <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<SetGrid nx="2" ny="3"/>
<Record element="data">
<ProcessNode select="animals" />
</Record>
<Record element="animals">
<PlaceObject>
<Table width="1" stretch="max" padding="3pt">
<Columns>
<Column width="1*"/>
<Column width="80mm"/>
<Column width="1*"/>
</Columns>
<Tablerule rulewidth="5mm" color="-"/>
<Tr>
<Td></Td>
<Td align="center" backgroundcolor="lightgreen">
<Paragraph>
<Value select="@title"></Value>
</Paragraph>
</Td>
<Td></Td>
</Tr>
<Tr>
<Td></Td>
<Td>
<Paragraph>
<ForAll select="item">
<Value select="." /><Br />
</ForAll>
</Paragraph>
</Td>
<Td></Td>
</Tr>
</Table>
</PlaceObject>
</Record>
</Layout> You can also place things in groups and place the groups on the grid without tables: <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<SetGrid nx="2" ny="3"/>
<Record element="data">
<ProcessNode select="animals" />
</Record>
<Record element="animals">
<Group name="foo">
<Contents>
<PlaceObject frame="solid">
<Textblock width="80mm">
<Paragraph>
<Value select="@title"/>
</Paragraph>
<ForAll select="item">
<Paragraph>
<Value>· </Value>
<Value select="."/>
<Switch>
<Case test="@new = 'true'">
<HSpace width="2pt" /><Image height="10pt" file="new.png"></Image>
</Case>
</Switch>
</Paragraph>
</ForAll>
</Textblock>
</PlaceObject>
</Contents>
</Group>
<PlaceObject column="{ ( position() - 1 ) mod 2 + 1}" row="{ (position() - 1 ) idiv 2 + 1}" groupname="foo" />
</Record>
</Layout> There is no good or correct way, there are always many possibilities. You have to play with the software to get a feeling what is possible. I know that the error messages are bad, and I constantly come across these messages and have no clue why things don't work. So you are not alone... |
Beta Was this translation helpful? Give feedback.
The second layout first: There is an error in the logic:
is on the top level (not within a
<Record ...>
element). Therefore the@title
and<ForAll select="item" >
has no "context", there is no current node in the data, so this will fail. You have to place this<SetVariable>
somewhere where there is a context node, for example in<Record element="animals" >
, but this will give you another prob…