|
inner wrote: XmlReader
string sxml = "<test>testing this</test>";
System.IO.StringReader reader = new StringReader(sxml);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(XmlReader.Create(reader));
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I face the same problem...
The point I have no solution to till now is making the XslCompiledTransform object put its output in a string variable...
Any idea???
|
|
|
|
|
Continuing from the previous example:
string strXml = ...;
string strXsl = ...;
XslCompiledTransform trans = new XslCompiledTransform();
trans.Load(XmlReader.Create(new StringReader(strXsl)));
StringBuilder sb = new StringBuilder();
trans.Transform(XmlReader.Create(new StringReader(strXml)), XmlWriter.Create(sb));
string outXml = sb.ToString();
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hi All,
Here Is my XSL file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="1.5cm"
margin-right="1.5cm">
<fo:region-body margin-top="2cm"/>
<fo:region-after extent="1.5cm"/>
<fo:region-before extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simple">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates select="Title"/>
<xsl:apply-templates select="TableEntries"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="Title">
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="20pt"
space-after.optimum="1pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
<xsl:value-of select="Heading"/>
</fo:block>
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="18pt"
space-after.optimum="1pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
<xsl:value-of select="DateCreated"/>
</fo:block>
</xsl:template>
<xsl:template match="TableEntries">
<fo:block width="510pt">
<fo:table table-layout="fixed" width="510pt">
<xsl:if test="ClientName">
<fo:table-column column-width="50pt" font-size="7pt" border="1" border-color="black" border-style="solid" padding="2pt"/>
<fo:table-column column-width="50pt" font-size="7pt" border="1" border-color="black" border-style="solid" padding="2pt"/>
</xsl:if>
<fo:table-body>
<fo:table-row>
<xsl:for-each select="TableInfo">
<xsl:if test="ClientName">
<fo:table-cell>
<fo:block>
Client Name
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="ClientName"/>
</fo:block>
</fo:table-cell>
</xsl:if>
</xsl:for-each>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
</xsl:stylesheet>
Here is my Xml File:
<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='ClientLookUpResult.xsl'?>
<ClientLookUp>
<Title>
<Heading>Client Look-Up Result</Heading>
<DateCreated>Date Created: 06 July 2006 06:07PM</DateCreated>
</Title>
<TableEntries>
<TableInfo key="0">
<ClientName>Jan</ClientName>
</TableInfo>
<TableInfo key="1">
<ClientName>Koos</ClientName>
</TableInfo>
<TableInfo key="2">
<ClientName>Piet</ClientName>
</TableInfo>
<TableInfo key="3">
<ClientName>Gert</ClientName>
</TableInfo>
<TableInfo key="4">
<ClientName>San</ClientName>
</TableInfo>
</TableEntries>
</ClientLookUp>
When i run fop, it doesn't display anything...
Plz help.
He who laughs last...
|
|
|
|
|
Can you post what the XML:FO looks like after running the XML through this stylesheet. Offhand, it looks to me like these lines will never match anything:
<xsl:if test="ClientName">
<fo:table-column column-width="50pt" font-size="7pt" border="1" border-color="black" border-style="solid" padding="2pt"/>
<fo:table-column column-width="50pt" font-size="7pt" border="1" border-color="black" border-style="solid" padding="2pt"/>
</xsl:if>
Logifusion[^]
|
|
|
|
|
ok hold on... This is going to take a while
He who laughs last...
|
|
|
|
|
Sorry, but how do i get the xml:fo?
He who laughs last...
|
|
|
|
|
Try just applying the stylesheet to your XML outside of the FO processor. In FOP, you can use the command line option -foout.
Logifusion[^]
|
|
|
|
|
hi, i read up on this xmlfo file.
I'm using the cmd "path\fop.bat" -xml "path\filename.xml" -xsl "path\filename.xsl" -pdf "path\filename.pdf" in the cmd prompt to create the pdf. But in this way i never see the xmlfo file.
i read that i can use xalan.bat to create a xslfo file... but i have no idea how use the file with command prompt. it was easy with the fop.bat because the internet was full of helpfull stuff but no such luck with the xalan.bat as of yet...
how do you create your xmlfo files?
He who laughs last...
|
|
|
|
|
NarutoFan69 wrote: cmd "path\fop.bat" -xml "path\filename.xml" -xsl "path\filename.xsl" -pdf "path\filename.pdf"
Just modify your command:
path\fop.bat -xml "path\filename.xml" -xsl "path\filename.xsl" -foout "path\filename_out.xml"
Logifusion[^]
|
|
|
|
|
it runs but not as it would when i use -pdf as an out file...
the -foout gives me the options of all the possible outfiles and switches and then it starts...
[info]Using org.apache.xerces.parser.SAXParser as SAX2 Parser
[info]FOP 0.20.5
[info]using org.apache.xerces.parser.SAXParser as SAX2 Parser
[error]null
He who laughs last...
|
|
|
|
|
I'll take a look at it in a few minutes to see if I can produce an XML for you. You might have a different version of FOP, or there might be some kind of problem with the parsing.
Logifusion[^]
|
|
|
|
|
ok thank you but before you do i think i found something. Now i can display the "title" section in the pdf document i created...
instead of using <xsl:template match="/"> in the beginning, i'm using <xsl:temlate match="ClientLookUp">
and then i'm apply that template too.
Like this...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="ClientLookUp">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="1.5cm"
margin-right="1.5cm">
<fo:region-body margin-top="2cm"/>
<fo:region-after extent="1.5cm"/>
<fo:region-before extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simple">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates select="ClientLookUp"/>
<xsl:apply-templates select="Title"/>
<xsl:apply-templates select="TableEntries"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="Title">
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="20pt"
space-after.optimum="1pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
<xsl:value-of select="Heading"/>
</fo:block>
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="18pt"
space-after.optimum="1pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
<xsl:value-of select="DateCreated"/>
</fo:block>
</xsl:template>
<xsl:template match="TableEntries">
<fo:block width="510pt">
<fo:table table-layout="fixed" width="510pt">
<xsl:if test="TableInfo/ClientName">
<fo:table-column column-width="50pt" font-size="7pt" border="1" border-color="black" border-style="solid" padding="2pt"/>
<fo:table-column column-width="50pt" font-size="7pt" border="1" border-color="black" border-style="solid" padding="2pt"/>
</xsl:if>
<fo:table-body>
<fo:table-row>
<xsl:for-each select="TableInfo">
<xsl:if test="ClientName">
<fo:table-cell>
<fo:block>
Client Name
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="ClientName"/>
</fo:block>
</fo:table-cell>
</xsl:if>
</xsl:for-each>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
</xsl:stylesheet>
He who laughs last...
|
|
|
|
|
Ah, now we're getting somewhere. First of all, I think you should download a newer version of FOP, because the one you have doesn't seem to have all the features you need. I'm currently working with 0.91beta, but there's a 0.92. Head out here to download it: http://xmlgraphics.apache.org/fop/download.html[^]
The next thing is that you changed the first template match and that's fine, but don't do this:
<xsl:apply-templates select="ClientLookUp"/>
It's just an unnecessary call and it's only going to confuse you as to how the template matching works. The first template you have was matching on the document root but wasn't actually going into the document element. It couldn't see Title and TableEntries because they were one level deeper than where it was looking.
Also, my version of FOP is giving your XSL the following error: For fo:simple-page-master, fo:region-before must be declared before fo:region-after.
So, in your ClientLookUp template, reverse the order of region-before and region-after:
<fo:region-body margin-top="2cm"/>
<fo:region-before extent="1.5cm"/>
<fo:region-after extent="1.5cm"/>
This at least gets your PDF to come out. I'm sure it's not going to look like you want it to, but at least this gives you something you can look at.
Logifusion[^]
|
|
|
|
|
Thank you
He who laughs last...
|
|
|
|
|
Thanks for your help... i've done it.
There is still one thing though... Is it possible to go to a new row if the column is at the end of a page? Because i give the user the option to select what he/she wants to see on the report but if they choose to see everything i have a problem... i line up the columns next to each other and as it reaches the end of the page i want it to go to the next row. I just need to know if it is possible, i'll find a way if it is...
my xml and xsl is in the next post.
He who laughs last...
|
|
|
|
|
My first reaction is that you really wouldn't be able to do this. It's kind of like an HTML table, it just doesn't wrap around to the next row. Instead, I would say you change the page layout to landscape. If the business won't move, I'd just reduce the font to a point where everything will fit. That's usually enough to convince them to go to landscape.
Logifusion[^]
|
|
|
|
|
LOL
Thanks.
But going landscape wouldn't work... i think... Say that the result brings back loads of records and the user only selected to see the client names. It would be a waste. But thanks never the less.
He who laughs last...
|
|
|
|
|
Last Question...
i still have the problem of displaying the selected items next to each other and if the columns reach the end of the page that it should go to the next line. Is it possible to say <in a if statement> that if the table width reaches a certain length, that it should insert a new row?
He who laughs last...
|
|
|
|
|
Here's the way I see it. You have to separate XSL from FO. Think of FO as being pretty much static. Although the FO processor will arrange FO blocks to create the pages, there is no conditional control that happens in FO (which can be very annoying). XSL is where all the conditional control happens. The trouble is that XSL will not know things about FO like widths or heights. You can write an if statement into your XSL, but it doesn't know if the table columns will extend too far across the page. So the only data you really know is how many columns you're going to put on the table.
Based on the number of columns, you can write your XSL to create two table rows per row of data. You could also do other things like reduce font size or change the layout of that page to landscape (but that's more trouble than it's worth).
HTH
Logifusion[^]
|
|
|
|
|
What if i created a counter <not shure how> that i incrament each time a column is created, when the counter reaches a cetain amount <lets say 6> create a new row?
He who laughs last...
-- modified at 12:18 Wednesday 12th July, 2006
|
|
|
|
|
You could create an <xsl-variable> to hold your counter. When it hits a certain number, end the current row and start another one. I think that's a good solution.
Logifusion[^]
|
|
|
|
|
Thanks for your time...
He who laughs last...
|
|
|
|
|
hi, i just wanted to tell you, you were right. I made the font very small and my boss told me to landscape. thank you for all your help.
He who laughs last...
|
|
|
|
|