Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About omegared

  • Rank
  1. Here is my xml and stylehseet, reading all is not neccessary:As you can see all parameter elements have the same name so i cant select a speicifc node by name. i also cant use someting like select parameter[1] because i will be shuffling the parameter order.Basically I want to first select a parameter based on the <parameter><name> node e.g first node would be 'book name'. I dont want to output this but rather the <value> node of that parameter.As you can see i found <xsl:apply-templates select="parameter/name[. =book name]"/> but I want to ouput the <value> element of that <parameter> abd not the <name> element. Can anyone help. Many thanks. <?xml version="1.0" encoding="UTF-8"?><data> <parameters> <parameter> <name> book name </name> <description> What is the books name </description> <valuetype> String </valuetype> <value>Java: How to Program</value> <defaultValue>Sham </defaultValue> </parameter> <parameter> <name> author </name> <description> who is the author </description> <valuetype> String </valuetype> <value>O Reily</value> <defaultValue> </defaultValue> </parameter> <parameter> <name> publisher </name> <description> who is the publisher </description> <valuetype> String </valuetype> <value>penguin books</value> <defaultValue> </defaultValue> </parameter></data><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">.... ates select="data"/> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template match="data"> <fo:block> <xsl:apply-templates select="parameter/name[. =author]"/> <fo:block text-align="center" display-align="center" background-color="orange"> <fo:external-graphic src="src/templates/java.gif" scaling="non-uniform" content-width="6cm" content-height="10cm"/> </fo:block> <xsl:apply-templates select="parameter[2]"/> <xsl:apply-templates select="parameter[3]"/> </fo:block> </xsl:template> <xsl:template match="parameter[3]"> <fo:block font-size="20pt" font-family="sans-serif" space-after.optimum="20pt" space-before.optimum="12pt" text-align="center" line-height="15pt"> <xsl:value-of select="value"/>publications </fo:block></xsl:template><xsl:template match="parameter[2]"> <fo:block font-size="20pt" font-style="italic" font-family="sans-serif" line-height="15pt" space-after.optimum="30pt" space-before.optimum="40pt" text-align="center">By <xsl:value-of select="value"/> </fo:block></xsl:template><xsl:template match="parameter/name[. =author]"> <fo:block font-size="28pt" font-weight="bold" font-family="sans-serif" line-height="10pt" space-after.optimum="30pt" space-before.optimum="200pt" text-align="center"> <xsl:value-of select=""/> </fo:block></xsl:template> </xsl:stylesheet>
  2. Actually having done some searching it would seem the previous is not relevevant. However I did find this link:http://www.dpawson.co.uk/xsl/sect2/onefile.html#d11001e15Would anybody be able to use this to change my hello world files. i have been trying but can't get anywhere.cheers
  3. I posted this elsewhere and somebody gave a response but I don't understand it. Hes reply was: You can view the XSLT FAQ about the identity transformation: http://www.dpawson.co.uk/xsl/sect2/identity.html Basically, try something like that for the first transformation: <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:x_="http://www.fgeorges.org/Transform/Alias" version="2.0"> <xsl:namespace-alias stylesheet-prefix="x_" result-prefix="xsl"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="fo:*/text()"> <!-- Try to set a variable, instead. --> <x_:value-of select="doc('')/to-datas/{.}"/> </xsl:template> </xsl:transform> It will transform the fo:* elements by wrapping their text nodes into xsl:value-of elements. So you'll give an XSLT script. Then use this script as usual, to produce the FO. You'll have maybe to customize the template rule matching "/", depending on what your document looks like (is it an FO or XSLT document?, etcetera).If anybody understands this, would you be kind enough as to modify my hello world program to demonstrate how the file would be.Many thanks
  4. I am new to this so i would be grateful if someone could help me through this simple example. At the moment I have an xml file and a xsl(fo) file. I am feeding them to apache fop to create pdf. I now want to place the xml and xsl in one file whilst being able to use xpath references to the data model rather then the text values.Would someone be kind enough as to show me how to convert my existing hello world files to achieve:A)place both xml and xsl in one file(how would the new file look)Existing xml file:<?xml version="1.0" encoding="UTF-8"?><data> <param1>hello</param1> <param2>world</param2></data>Existing 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="0.2cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm"> <fo:region-body margin-top="2cm"/> <fo:region-before extent="3cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="simple"> <fo:flow flow-name="xsl-region-body"> <xsl:apply-templates select="data"/> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template match="data"> <fo:block> <xsl:apply-templates select="param1"/> <xsl:apply-templates select="param2"/> </fo:block> </xsl:template><xsl:template match="param1"> <fo:block font-size="12pt" font-family="sans-serif" space-after.optimum="30pt" text-align="justify"> <xsl:value-of select="."/> </fo:block></xsl:template><xsl:template match="param2"> <fo:block font-size="12pt" space-before.optimum="110pt" text-align="justify"> <xsl:value-of select="."/> </fo:block></xsl:template></xsl:stylesheet>Sincere thanks
  5. Cheers mate, it worked!
  6. HiI am using xsl:if to output a table only when my current nodes is not empty. The problem is that when the current node is empty, a line appears which I believe is the table border. I don't know why the line is appearing. My code is:Snippet of my xml:<member> <name>John Doe</name> <function>lead</function> <email>jon.doe@killerapp.fun</email> </member> <member> <name>Paul Coder</name> <function>dev</function> <email>paul.coder@killerapp.fun</email> </member>Xslt for table template:<xsl:template match="member"> <xsl:if test='true()'> <fo:block font-size="10pt"> <fo:table border-width="0.1mm" border-style="solid" table-layout="fixed" width="100%"> <fo:table-column column-width="4cm"/> <fo:table-column column-width="4cm"/> <fo:table-column column-width="5cm"/> <fo:table-body> <fo:table-row> <fo:table-cell> <fo:block> <xsl:value-of select="name"/> </fo:block> </fo:table-cell> <fo:table-cell> <fo:block> <xsl:value-of select="function"/> </fo:block> </fo:table-cell> <fo:table-cell> <fo:block> <xsl:value-of select="email"/> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> </xsl:if></xsl:template>
  7. When applying inline styles such as bold. Italic or underline this is accomplished by using something like <fo:block font="12pt Arial"> hello <fo:inline font-weight="bold" color="red">world</fo:inline> </fo:block>.However in this example the data and format is not separated. I am using <xsl:value-of select=”.”> (where .=”hello world”). If I used <fo:inline font-weight="bold" color="red"><xsl:value-of select=”.”></fo:inline> it would change both 'hello' and 'world'. How do you specify you want to change world only when you have seperated content and formatting?Many thanks
  8. HiI am new to XSL and was hoping somebody would be kind enough to answer the following questions. I have read a number of online tutorials but they do not go above a very basic introduction. Please answer these questions in the context of using xml and xslt to seperate content and format.1)If I want to apply exactly the same template to a node which has a different name, how do I do this. At the moment I am copy/pasting the whole template and changing the nodename in 'match=nodename'. Do I have to copy the whole template everytime? Is there no way I can reuse the same template by sating something like:<apply template select =“template1”><value-of=/nodeA></apply template><apply template select =“template1”><value-of=nodeJ></apply template>2)Suppose you have two paragraphs which have identical formatting e.g. font size, colour, style except that one paragraph begins with has different alignment. At the moment I am writing two templates e.g.<xsl:template match="para1"> <fo:block text-indent="0.5in" font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="12pt" text-align="right"> <xsl:value-of select="."/> </fo:block></xsl:template>and <xsl:template match="para2"> <fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="12pt" text-align="right"> <xsl:value-of select="."/> </fo:block></xsl:template>Is there no way of saying apply all of the template specification in para1 to para2 but change the alignment with out repeating the same styling definitions? D I have to write separate templates every time regardless?Can someone at least direct me to the properties I should be looking at for both questions. Many thanks.
  9. ok ok i found the answer. just add src=filelocation to the instance tag. So does anyone know of any good tutorials where i can learn about implementing treeviews and complex navigation and what not. cheers.
  10. Hi GuysI have a simple form which writes my xfrom instance data to an xml file, all working fine. Here is a snippet:" <xf:model> <xf:instance> <order xmlns=""> <client xmlns=""> <fname></fname> <lname></lname> </client> </order> </xf:instance> <xf:submission id="s1" method="put" action="C:\Documents and Settings\miah_s\Desktop\Sham Xforms\myData.xml"/>..."What I want to know is, how do I get the text fields to be set by reading from the .xml file on start up. I know |I can fill the model up in the xhtml but i want the data in the .xml to be used. I know this is an easy one but i cant find anything online due to the messy or non existant nature of the learning material.Many thanks.
  • Create New...