Re: XSLT Question
Hi, Jay, hi, all, I'm currently close to a solution I was thinking of. but currently I don't understand following: This is the beginning of my new call template. As branch I support a list of nodes for the tree's next level. As tree-structure-string I support the list of currently needed images (in form of a string) before this tree branch. in the for-each I decide for each element if it is the last one or not, needed for finding the image to be added in this tree level and for the next level. So far for now, but when I tried to debug the XSL Transformation I found that $tree-structure-new-branch is not set to a value. In my case it took the xsl:otherwise route, but value isn't set. What did I wrong? Regards, Kai xsl:template name=tree-master xsl:param name=branch/ xsl:param name=tree-structure-string/ xsl:for-each select=$branch xsl:variable name=tree-structure-new-branch xsl:choose !-- if this node is not last... -- xsl:when test=not(position()=last()) img width=16 height=16 alt=the branch is not finished/ /xsl:when xsl:otherwise img width=16 height=16 alt=This is the last element of the branch/ /xsl:otherwise /xsl:choose /xsl:variable Hi, Jay, I try your solution tomorrow to see how it looks like. If I found a better solution I will tell you here :-) But many thanks for your hints! Kai Hi, Kai, The following stylesheet, applied to the following XML (an extension of your example), generates the same tree view as used by the Acrobat Reader (at least in version 7): XSL: ?xml version=1.0 encoding=UTF-8? xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:template match=objects html head titleTest/title /head style lt;!-- td {font-family:monospace} --gt; /style body table xsl:apply-templates/ /table /body /html /xsl:template xsl:template match=object tr td xsl:for-each select=ancestor::object[not(position()=last())] xsl:choose xsl:when test=generate-id(.)=generate-id(../*[last()]) #160;#160; /xsl:when xsl:otherwise |#160; /xsl:otherwise /xsl:choose /xsl:for-each xsl:choose xsl:when test=generate-id(.)=generate-id(../*[last()]) xsl:if test=..[not(name()='objects')]#160;-/xsl:if xsl:value-of select=@id/ /xsl:when xsl:otherwise |-xsl:value-of select=@id/ /xsl:otherwise /xsl:choose xsl:apply-templates/ /td /tr /xsl:template xsl:template match=relation xsl:apply-templates/ /xsl:template /xsl:stylesheet XML: objects object Level=0 id=01 relation Level=0 object Level=1 id=11 relation Level=1 object Level=2 id=21 relation Level=2 object Level=3 id=31/ object Level=3 id=32/ /relation /object object Level=2 id=22 relation Level=2 object Level=3 id=33 relation Level=3 object Level=4 id=41/ object Level=4 id=42/ /relation /object object Level=3 id=34 relation Level=3 object Level=4 id=43/ object Level=4 id=44/ /relation /object /relation /object object Level=2 id=23 relation level=2 object Level=3 id=35/ object Level=3 id=36/ /relation /object /relation /object /relation /object /objects Note that the relation elements and Level attributes are unnecessary. If you have control over the application that generates the XML, you could eliminate them. In that case you could alse eliminate the match=relation template in the XSL. If you want a line down the left-most edge, I'll have to leave that to you. I have run out of the time that I can spend on someone else's project. I did enjoy having something different to work on, though. Thanks. Jay Bryant Bryant Communication Services (presently consulting at Synergistic Solution Technologies) Kai Hackemesser [EMAIL PROTECTED] 02/21/2005 11:45 AM Please respond to [EMAIL PROTECTED] To [EMAIL PROTECTED] cc Subject Re: XSLT Question Hi J
XSLT Question
Hello, I know this is not quite the right mailing list for that question, but maybe somebody here knows? I need to create a kind of recursive call-template, where certain attributes from different parent elements are needed. I want to do a call to a template by itself, giving it the parent element as parameter. Ho can I evaluate the parent of a parameter given node? Or how do I set a parent element to be current() element? While in a call? Regards, Kai - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: XSLT Question
Hi, Jay, ok, here more details: my XML source looks like that: ... object Level=0 relation Level=0 object Level=1 relation Level=1 object Level=2 ... /object /relation /object object Level=1 relation Level=1 object Level=2 ... I think you got the structure. There are attribute elements and a lot of element attributes I now haven't shown because not needed for my question. I have to create a explorer tree like picture from that. For each line of my list I need to find out what tree structure images are needed (u2503; u2523; u2517; in form of fixed size gif images), I need to know for example if this element is the last child of its parent, if the parent is the last child of its parent and so on, to decide which image is the correct. I need it recursive because there is theoretical no limit of depth, practical it would lie at about ten. My solution was about this: xsl:template match=object tr td xsl:call-template name=tree-scructure xsl:with-param name=treenode select=node()/ /xsl:call-template xsl:value-of select=[EMAIL PROTECTED]'DisplayedName']/value/ /td td xsl:call-template name=replace-null xsl:with-param name=input select=[EMAIL PROTECTED]'beGTABeschreibPos']/value/ /xsl:call-template /td td xsl:value-of select=attribute [EMAIL PROTECTED]'LifeCycleState']/value/ /td td xsl:value-of select=[EMAIL PROTECTED]'ProjectName']/value/ /td /tr xsl:apply-templates select=relation/ /xsl:template xsl:template match=relation tr td xsl:call-template name=tree-scructure xsl:with-param name=treenode select=node()/ /xsl:call-template xsl:value-of select=[EMAIL PROTECTED]'LDisplayedName']/value/ /td /tr xsl:apply-templates select=object/ /xsl:template xsl:template name=tree-scructure xsl:param name=treenode/ xsl:param name=recursive/ xsl:if test=$treenode/@Level 0 xsl:call-template name=tree-scructure xsl:with-param name=treenode select=parent::node()/ xsl:with-param name=recursivetrue/xsl:with-param /xsl:call-template /xsl:if img width=16 height=16 alt=just an incomplete test/ /xsl:template That's where I am now a not working thing. Thank you for your time, Kai Hi, Kai, I would need a bit more detail to be able to help with that. Please post the smallest (but still still complete) set of XML files (input and desired output) that you want. That way, we can see what you mean. A couple observations, though: You can't walk back up the tree from a parameter passed to a template by using path expressions. Thus, you can't get the parent of a node you passed as a parameter by using .. or a similar construct. If memory serves, this problem arises because, when you pass a path as a parameter, you really pass a result tree fragment. Unfortunately, the result tree fragment has its own root node (the node you passed), so you can't go up from there. To solve this problem, you need more information. In the past, I have used a text representation of the full path (from the document root) to the node I want. Then I can use the name() function and predicate logic to walk back up the path. If you only need to go up one level, you could pass the parent node as another parameter. That method is not extensible, but it will work, so long as you really only need to go up one level. Also, you should subscribe to [EMAIL PROTECTED] and ask that question there. The heavy hitters in the XSL world read that list. HTH Jay Bryant Bryant Communication Services (presently consulting at Synergistic Solution Technologies) Kai Hackemesser [EMAIL PROTECTED] 02/21/2005 09:27 AM Please respond to [EMAIL PROTECTED] To [EMAIL PROTECTED] cc Subject XSLT Question Hello, I know this is not quite the right mailing list for that question, but maybe somebody here knows? I need to create a kind of recursive call-template, where certain attributes from different parent elements are needed. I want to do a call to a template by itself, giving it the parent element as parameter. Ho can I evaluate the parent of a parameter given node? Or how do I set a parent element to be current() element? While in a call? Regards, Kai - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
Re: XSLT Question
Hi J, Partly you are right, with your test I can tell what image I need for the current level of the tree, but I can't see how to retrieve the required images from lower levels. the test you described needs to be done for every element up to level 0. It's not just the Indent which I want to show, but also some lines and branches, depending from the structure. Like the folder tree in an windows explorer window. Ciao! Kai Hi, Kai, I don't think you need to call a template for that. You can test for the characteristics of the node from within the matching template and get the image you need. Several xsl:when statements within an xsl:choose block should let you figure out which images to use when. For example, xsl:when test=generate-id(.)=generate-id(../*[last()]) will tell you whether the current node is the last child node of its parent. Also, to indent properly, you can read the Level attribute and put the appropriate number of indentation objects (blank table cells, spaces, whatever you use) before the image. J - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: XSLT Question
Hi, Jay, The first example is the perfect hit: Key: |-A node that is not the last node at its level -A node that is the last node at its level | Continuation of an ancestor level Root |-Dir1 | |-File11 | -File12 |-Dir2 | |-File21 | |-File22 | |-Dir21 | | |-File211 | | -File212 | -Dir22 | -File221 -Dir3 In the first case, you need either a for-each or a recursive template to generate all the continuation images and space them properly. Thats what I'm searching a solution for ... From a user-interface design point of view, by the way, the second view is much better. The first is very cluttered. All those lines draw the eye away from the information that matters without adding any value. If you must do the first, you should make the lines NOT stand out (light grey and thin lines would do). Customer wishes *sigh* By the way, the Windows XP Explorer just has boxes with + and - signs. It has no lines at all, relying purely on indentation to show the relation between levels. In my view, that's one of the things Microsoft did right. You are right! I maybe had another tool in mind, TreeSize or such. Ciao! Kai - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: XSLT Question
Hi, Jay, I try your solution tomorrow to see how it looks like. If I found a better solution I will tell you here :-) But many thanks for your hints! Kai Hi, Kai, The following stylesheet, applied to the following XML (an extension of your example), generates the same tree view as used by the Acrobat Reader (at least in version 7): XSL: ?xml version=1.0 encoding=UTF-8? xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:template match=objects html head titleTest/title /head style lt;!-- td {font-family:monospace} --gt; /style body table xsl:apply-templates/ /table /body /html /xsl:template xsl:template match=object tr td xsl:for-each select=ancestor::object[not(position()=last())] xsl:choose xsl:when test=generate-id(.)=generate-id(../*[last()]) #160;#160; /xsl:when xsl:otherwise |#160; /xsl:otherwise /xsl:choose /xsl:for-each xsl:choose xsl:when test=generate-id(.)=generate-id(../*[last()]) xsl:if test=..[not(name()='objects')]#160;-/xsl:if xsl:value-of select=@id/ /xsl:when xsl:otherwise |-xsl:value-of select=@id/ /xsl:otherwise /xsl:choose xsl:apply-templates/ /td /tr /xsl:template xsl:template match=relation xsl:apply-templates/ /xsl:template /xsl:stylesheet XML: objects object Level=0 id=01 relation Level=0 object Level=1 id=11 relation Level=1 object Level=2 id=21 relation Level=2 object Level=3 id=31/ object Level=3 id=32/ /relation /object object Level=2 id=22 relation Level=2 object Level=3 id=33 relation Level=3 object Level=4 id=41/ object Level=4 id=42/ /relation /object object Level=3 id=34 relation Level=3 object Level=4 id=43/ object Level=4 id=44/ /relation /object /relation /object object Level=2 id=23 relation level=2 object Level=3 id=35/ object Level=3 id=36/ /relation /object /relation /object /relation /object /objects Note that the relation elements and Level attributes are unnecessary. If you have control over the application that generates the XML, you could eliminate them. In that case you could alse eliminate the match=relation template in the XSL. If you want a line down the left-most edge, I'll have to leave that to you. I have run out of the time that I can spend on someone else's project. I did enjoy having something different to work on, though. Thanks. Jay Bryant Bryant Communication Services (presently consulting at Synergistic Solution Technologies) Kai Hackemesser [EMAIL PROTECTED] 02/21/2005 11:45 AM Please respond to [EMAIL PROTECTED] To [EMAIL PROTECTED] cc Subject Re: XSLT Question Hi J, Partly you are right, with your test I can tell what image I need for the current level of the tree, but I can't see how to retrieve the required images from lower levels. the test you described needs to be done for every element up to level 0. It's not just the Indent which I want to show, but also some lines and branches, depending from the structure. Like the folder tree in an windows explorer window. Ciao! Kai Hi, Kai, I don't think you need to call a template for that. You can test for the characteristics of the node from within the matching template and get the image you need. Several xsl:when statements within an xsl:choose block should let you figure out which images to use when. For example, xsl:when test=generate-id(.)=generate-id(../*[last()]) will tell you whether the current node is the last child node of its parent. Also, to indent properly, you can read the Level attribute and put the appropriate number of indentation objects (blank table cells, spaces, whatever you use) before the image. J - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
are there alternatives to Apache FOP?
Hello, all, I am looking for a good FO-PDF converter. I tried so far FOP from Apache, but it looks like it currently doesn't support all features I would like to use (for example all border styles I tried result in solid borders, and the border collapsing sometimes doesn't look nice) So what are the currently available alternatives? Regards, Kai - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ezmlm response
Hello, all, I'm quite fresh to FOP, so I need some assistance with following error message: [DEBUG] Input mode: [DEBUG] FO [DEBUG] fo input file: c:\Documents and Settings\behr\Local Settings\Temp\proC5.xml [DEBUG] Output mode: [DEBUG] pdf [DEBUG] output file: C:\DOCUME~1\behr\LOCALS~1\Temp\posC6.pdf [DEBUG] OPTIONS [DEBUG] no user configuration file is used [default] [DEBUG] debug mode on [DEBUG] dump configuration [DEBUG] quiet mode on [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] base directory: file:/c:/Documents and Settings/behr/Local Settings/Temp/ [INFO] FOP 0.20.5 [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] building formatting object tree [INFO] setting up fonts [ERROR] null org.apache.fop.apps.FOPException at org.apache.fop.apps.CommandLineStarter.run(CommandLineStarter.java:111) at org.apache.fop.apps.Fop.main(Fop.java:62) - java.lang.NullPointerException at org.apache.fop.fo.PropertyManager.getTextDecoration(PropertyManager.java:365) at org.apache.fop.fo.FObjMixed.init(FObjMixed.java:72) at org.apache.fop.fo.flow.Block.init(Block.java:115) at org.apache.fop.fo.flow.Block$Maker.make(Block.java:79) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:352) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.fop.apps.Driver.render(Driver.java:498) at org.apache.fop.apps.CommandLineStarter.run(CommandLineStarter.java:106) at org.apache.fop.apps.Fop.main(Fop.java:62) - java.lang.NullPointerException at org.apache.fop.fo.PropertyManager.getTextDecoration(PropertyManager.java:365) at org.apache.fop.fo.FObjMixed.init(FObjMixed.java:72) at org.apache.fop.fo.flow.Block.init(Block.java:115) at org.apache.fop.fo.flow.Block$Maker.make(Block.java:79) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:352) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.fop.apps.Driver.render(Driver.java:498) at org.apache.fop.apps.CommandLineStarter.run(CommandLineStarter.java:106) at org.apache.fop.apps.Fop.main(Fop.java:62) What is the problem FOP is crying about, and how can I solve it? Regards, Kai - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]