Subject: RE: [xsl] can't display heading in between fields...pls. help From: "John Liebermann" <ahsan_hussain@xxxxxxxxxxxxx> Date: Thu, 17 Jul 2003 14:10:19 -0700 |
Markus, sorry about the confusion. I think i am bad at explaining what i am trying to do. Your solution might be correct in its own right but it still doesn't solve my problem. By separating the templates for <HSDataContainerType> the code looks better. I tried it earlier as well but it only puts the heading 'Output Description' before my 'Outputs' in the TREE. I would like this heading to be in between my target links at the bottom. Attached below you will see both the XSL i wrote and the XML i am converting to HTML. You will see that if you click on Input (up in the tree) you will be taken down to where the inputs start. Same for Outputs. I would like to put a heading 'Input Descriptions' at the very point the Inputs start. Same for Outputs. This is the point where the link takes you. Here is how i want the complete output: ------------------------------------------ Contract Name: myWebservice ID: 25_610_15006485306 Start Date: Jul-23-2003 Inputs textField_1 integerField_1 decimalField_1 DataContainer_1_1 textField_1_1 integerField_1_1 DataContainer_1_1_1 textField_1_1_1 integerField_1_1_1 Outputs NoValueRestrictions required optional_NoDefault optional_withDefault TextValueRestrictions restrictByValue restrictByRange restrictByRangeNoMIN restrictByRangeNoMAX restrictByPattern NumberValueRestrictions restrictByValue restrictByRange restrictByPattern OtherRestrictions BinaryRestrictions Short Description: This is an example of a complex set of inputs. Long Description: My way or the highway. My way or the highway. My way or the highway. My way or the highway. My way or the highway. My way or the highway. My way or the highway. Descriptions <-- this is where the inputs start, so put heading 'Input Description' textField_1 Description: textField_1_Documentation Required: No Default Value: hello The value must match the following pattern: None integerField_1 Description: None Required: Yes Value Restrictions: None decimalField_1 Description: None Required: Yes Value Restrictions: None DataContainer_1_1/ textField_1_1 Description: None Required: Yes Value Restrictions: None DataContainer_1_1/ integerField_1_1 Description: None Required: Yes Value Restrictions: None DataContainer_1_1/ DataContainer_1_1_1/ textField_1_1_1 Description: None Required: Yes Value Restrictions: None DataContainer_1_1/ DataContainer_1_1_1/ integerField_1_1_1 Description: None Required: Yes Value Restrictions: None <-- this is where the outputs start, so put heading 'Output Description' NoValueRestrictions/ required Description: None Required: Yes Value Restrictions: None NoValueRestrictions/ optional_NoDefault Description: None Required: No Default Value: None Value Restrictions: None NoValueRestrictions/ optional_withDefault Description: None Required: No Default Value: This is the default value Value Restrictions: None TextValueRestrictions/ restrictByValue Description: None Required: Yes Only the following values are allowed: CA; WA; VA; TextValueRestrictions/ restrictByRange Description: None Required: Yes Max Number of Characters: 0 Max Number of Characters: 100 TextValueRestrictions/ restrictByRangeNoMIN Description: None Required: Yes Min Number of Characters: None Max Number of Characters: 500 TextValueRestrictions/ restrictByRangeNoMAX Description: None Required: Yes Max Number of Characters: 40 Min Number of Characters: None TextValueRestrictions/ restrictByPattern Description: None Required: Yes The value must match the following pattern: ^Pattern NumberValueRestrictions/ restrictByValue Description: None Required: Yes Only the following values are allowed: 10; 20; 30; NumberValueRestrictions/ restrictByRange Description: None Required: Yes The value must match the following pattern: None NumberValueRestrictions/ restrictByPattern Description: None Required: Yes The value must match the following pattern: $1234 -------------------------------------------------- So now when i click on Inputs (in the TREE up top), it should take me to the point in the descriptions section where the inputs start i.e textField_1 It is doing that right now but there in NO HEADING THERE (above textFiele_1 in the desriptions). I would like to put a heading there (as poined by arrows in output) and take the user there when they click on 'Inputs'. Same for Outputs. i would recommend pasting both in an XSL editor such as Xselerator and then looking at the generated HTML. Any help on this would be appreciated. Thanks once again Markus. John Liebermann XSL: --------------------------------------------------- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="HSContract"> <html> <head> <title/> </head> <body> <!--<p><a href="#desc"><b>Contract Name: </b><xsl:value-of select="@contractName"/><br /></a>--> <p><b>Contract Name: </b><xsl:value-of select="@contractName"/><br /> <b>ID: </b><xsl:value-of select="@id"/><br /> <b>Start Date: </b><xsl:value-of select="@startDate"/><br /></p> <xsl:apply-templates select="HSDataContainerType[@name='Inputs']"/> <xsl:apply-templates select="HSDataContainerType[@name='Outputs']"/> <xsl:apply-templates select="HSDocumentation"/> <xsl:apply-templates select="//HSString | //HSDouble | //HSInteger" mode="target" /> </body> </html> </xsl:template> <!-- if @name = Inputs, make it a link --> <xsl:template match="HSDataContainerType[contains(@name, 'Inputs')]"> <img src="dcopenicon.gif"> <a href="#in"><b><xsl:value-of select="@name"/></b></a></img> <div style="margin-left: 3em;"> <xsl:apply-templates select="*"/></div> </xsl:template> <xsl:template match="HSDataContainerType[contains(@name, 'Outputs')]"> <img src="dcopenicon.gif"> <a href="#out"><b><xsl:value-of select="@name"/></b></a></img> <div style="margin-left: 3em;"> <xsl:apply-templates select="*"/></div> </xsl:template> <xsl:template match="HSDataContainerType"> <b><img src="dcopenicon.gif"> <xsl:value-of select="@name"/></img><br /></b> <div style="margin-left: 3em;"> <xsl:apply-templates select="*"/></div> </xsl:template> <xsl:template name="Heading"> <b>Output Description</b><br /> </xsl:template> <xsl:template match="*"> <div><xsl:apply-templates select="HSLinkString" /></div> <div><xsl:apply-templates select="HSLinkDouble"/></div> <div><xsl:apply-templates select="HSLinkInteger"/></div> </xsl:template> <xsl:template name="HSLinkString" match="//HSString"> <img src="texticon.gif"><a href="#{generate-id(.)}"> <xsl:value-of select="@name" /></a><br /></img> </xsl:template> <xsl:template name="HSLinkerString" match="HSString" mode="target"> <img src="texticon.gif"><a name="{generate-id(.)}"> <b><xsl:comment>Accessing the parent nodes...</xsl:comment> <xsl:for-each select="ancestor::*"> <xsl:choose> <xsl:when test="contains(@name, 'Inputs')"> <a name="in"></a> </xsl:when> <xsl:when test="contains(@name, 'Outputs') and not(ancestor::*[contains(@name,'Outputs')])"> <!-- <xsl:call-template name="Heading" /> --> <a name="out"></a> <xsl:if test="contains(@name, 'Outputs')"></xsl:if> </xsl:when> <xsl:when test="contains(@name, 'Settings')"> <a name="set"></a> </xsl:when> <xsl:otherwise> <xsl:if test="not(position()='1')"> <xsl:value-of select="@name" />/ </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:for-each> <!-- neccessary to put the path to the field --> <xsl:value-of select="@name" /></b></a></img> <br /> <!-- Handle HSDocumentation in here --> <xsl:text>Description: </xsl:text> <xsl:choose> <xsl:when test="normalize-space(HSDocumentation) = ''"> None<br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="HSDocumentation" /><br /> </xsl:otherwise> </xsl:choose> Required: <xsl:choose> <xsl:when test="contains(@required, 'true')"> Yes<br /> </xsl:when> <!-- if optional, then default value exists or doesn't exist--> <xsl:otherwise>No<br /> Default Value: <!--if default tag has some value, display otherwise say "No Default Value"--> <xsl:choose> <xsl:when test="normalize-space(DefaultValue) = ''"> None<br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="DefaultValue" /><br /> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="contains(@restrictType, '1')"> <!-- if restrictType = 1 then display restrictions--> Only the following values are allowed: <xsl:for-each select="restrictedValue"> <xsl:value-of select="text()" />; </xsl:for-each><br /> </xsl:when> <xsl:when test="contains(@restrictType, '2')"> <xsl:for-each select="restrictedValue"> <xsl:choose> <xsl:when test="normalize-space( text() ) = ''"> Min Number of Characters: <xsl:text>None</xsl:text><br /> </xsl:when> <xsl:otherwise> Max Number of Characters: <xsl:value-of select="text()" /><br/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:when test="contains(@restrictType, '3')"> <!-- if restrictType = 3 then say 'Pattern Allowed:' value--> <xsl:text>The value must match the following pattern: </xsl:text> <xsl:choose> <!-- <xsl:when test="normalize-space(text()) = ''"> --> <xsl:when test="restrictedValue[.='']"> <xsl:text>None</xsl:text><br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="restrictedValue" /><br /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> Value Restrictions: None<br /> </xsl:otherwise> </xsl:choose> <br /> </xsl:template> <xsl:template name="HSLinkDouble" match="//HSDouble"> <img src="decimalicon.gif"><a href="#{generate-id(.)}"> <xsl:value-of select="@name" /></a><br /></img> </xsl:template> <xsl:template name="HSLinkerDouble" match="HSDouble" mode="target"> <img src="decimalicon.gif"><a name="{generate-id(.)}"> <b> <xsl:comment>Accessing the parent nodes...</xsl:comment> <xsl:for-each select="ancestor::*"> <xsl:choose> <xsl:when test="contains(@name, 'Inputs')"></xsl:when> <xsl:when test="contains(@name, 'Outputs')"></xsl:when> <xsl:when test="contains(@name, 'Settings')"></xsl:when> <xsl:otherwise> <xsl:if test="not(position()='1')"> <xsl:value-of select="@name" />/ </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:value-of select="@name" /></b></a></img> <br /> <!-- Handle HSDocumentation in here --> <xsl:text>Description: </xsl:text> <xsl:choose> <xsl:when test="normalize-space(HSDocumentation) = ''"> None<br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="HSDocumentation" /><br /> </xsl:otherwise> </xsl:choose> Required: <xsl:choose> <xsl:when test="contains(@required, 'true')"> Yes<br /> </xsl:when> <!-- if optional, then default value exists or doesn't exist--> <xsl:otherwise>No<br /> Default Value: <!--if default tag has some value, display otherwise say "No Default Value"--> <xsl:choose> <xsl:when test="normalize-space(DefaultValue) = ''"> None<br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="DefaultValue" /><br /> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="contains(@restrictType, '1')"> <!-- if restrictType = 1 then display restrictions--> Only the following values are allowed: <xsl:for-each select="restrictedValue"> <xsl:value-of select="text()" />; </xsl:for-each><br /> </xsl:when> <xsl:when test="contains(@restrictType, '2')"> <xsl:for-each select="restrictedValue"> <xsl:choose> <xsl:when test="normalize-space( text() ) = ''"> Min Value Allowed: <xsl:text>None</xsl:text><br /> </xsl:when> <xsl:otherwise> Max Value Allowed: <xsl:value-of select="text()" /><br/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:when test="contains(@restrictType, '3')"> <!-- if restrictType = 3 then say 'Pattern Allowed:' value--> <xsl:text>The value must match the following pattern: </xsl:text> <xsl:choose> <!-- <xsl:when test="normalize-space(text()) = ''"> --> <xsl:when test="restrictedValue[.='']"> <xsl:text>None</xsl:text><br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="restrictedValue" /><br /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> Value Restrictions: None<br /> </xsl:otherwise> </xsl:choose> <br /> </xsl:template> <xsl:template name="HSLinkInteger" match="//HSInteger"> <img src="integericon.gif"><a href="#{generate-id(.)}"> <xsl:value-of select="@name" /></a><br /></img> </xsl:template> <xsl:template name="HSLinkerInteger" match="HSInteger" mode="target"> <img src="integericon.gif"><a name="{generate-id(.)}"> <b> <xsl:comment>Accessing the parent nodes...</xsl:comment> <xsl:for-each select="ancestor::*"> <xsl:choose> <xsl:when test="contains(@name, 'Inputs')"></xsl:when> <xsl:when test="contains(@name, 'Outputs')"></xsl:when> <xsl:when test="contains(@name, 'Settings')"></xsl:when> <xsl:otherwise> <xsl:if test="not(position()='1')"> <xsl:value-of select="@name" />/ </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:value-of select="@name" /></b></a></img> <br /> <!-- Handle HSDocumentation in here --> <xsl:text>Description: </xsl:text> <xsl:choose> <xsl:when test="normalize-space(HSDocumentation) = ''"> None<br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="HSDocumentation" /><br /> </xsl:otherwise> </xsl:choose> Required: <xsl:choose> <xsl:when test="contains(@required, 'true')"> Yes<br /> </xsl:when> <!-- if optional, then default value exists or doesn't exist--> <xsl:otherwise>No<br /> Default Value: <!--if default tag has some value, display otherwise say "No Default Value"--> <xsl:choose> <xsl:when test="normalize-space(DefaultValue) = ''"> None<br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="DefaultValue" /><br /> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="contains(@restrictType, '1')"> <!-- if restrictType = 1 then display restrictions--> Only the following values are allowed: <xsl:for-each select="restrictedValue"> <xsl:value-of select="text()" />; </xsl:for-each><br /> </xsl:when> <xsl:when test="contains(@restrictType, '2')"> <xsl:for-each select="restrictedValue"> <xsl:choose> <xsl:when test="normalize-space( text() ) = ''"> Min Value Allowed: <xsl:text>None</xsl:text><br /> </xsl:when> <xsl:otherwise> Max Value Allowed: <xsl:value-of select="text()" /><br/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:when test="contains(@restrictType, '3')"> <!-- if restrictType = 3 then say 'Pattern Allowed:' value--> <xsl:text>The value must match the following pattern: </xsl:text> <xsl:choose> <!-- <xsl:when test="normalize-space(text()) = ''"> --> <xsl:when test="restrictedValue[.='']"> <xsl:text>None</xsl:text><br /> </xsl:when> <xsl:otherwise> <xsl:value-of select="restrictedValue" /><br /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> Value Restrictions: None<br /> </xsl:otherwise> </xsl:choose> <br /> </xsl:template> <xsl:template name="HSDoc" match="HSDocumentation"> <p><b>Short Description: </b><br /><br /> <xsl:apply-templates select="shortDescription" /><br /><br /> <b>Long Description:</b><br /><br /> <xsl:apply-templates select="descriptionSection" /></p> </xsl:template> <xsl:template name="shortDescription" match="//shortDescription"> <xsl:value-of select="text()"/> </xsl:template> <xsl:template name= "descriptionSection" match="//descriptionSection"> <xsl:value-of select="text()"/><br /><br /> <p><b>Descriptions</b></p> <!-- <p><b><a name="in">Input Descriptions</a></b></p> --> </xsl:template> </xsl:stylesheet> ---------------------------------------- <HSContract contractCategory="2" contractName="myWebservice" contractType="3" expirationDate="Jun-23-2013" id="25_610_15006485306" limitMaxConcurrentThreads="false" logEnabled="true" maxConcurrentThreads="2" revision="25_33" runBatchInParallel="false" startDate="Jul-23-2003"> <imagePath /> <HSDataContainerType list="true" name="Inputs" required="true" revision="" systype="true"> <HSString name="textField_1" restrictType="3" xmlNodeType="1"> <DefaultValue>hello</DefaultValue> <HSDocumentation> <shortDescription><![CDATA[ textField_1_Documentation]]></shortDescription> </HSDocumentation> <restrictedValue /> </HSString> <HSInteger name="integerField_1" required="true" xmlNodeType="1" /> <HSDouble name="decimalField_1" required="true" xmlNodeType="1" /> <HSDataContainerType name="DataContainer_1_1" required="true" revision=""> <HSString name="textField_1_1" required="true" xmlNodeType="1" /> <HSInteger name="integerField_1_1" required="true" xmlNodeType="1" /> <HSDataContainerType name="DataContainer_1_1_1" required="true" revision=""> <HSString name="textField_1_1_1" required="true" xmlNodeType="1" /> <HSInteger name="integerField_1_1_1" required="true" xmlNodeType="1" /> </HSDataContainerType> </HSDataContainerType> </HSDataContainerType> <HSDataContainerType list="true" name="Outputs" required="true" revision="" systype="true"> <HSDataContainerType name="NoValueRestrictions" required="true" revision=""> <HSString name="required" required="true" xmlNodeType="1" /> <HSString name="optional_NoDefault" xmlNodeType="1"> <DefaultValue /> </HSString> <HSString name="optional_withDefault" xmlNodeType="1"> <DefaultValue>This is the default value</DefaultValue> </HSString> </HSDataContainerType> <HSDataContainerType name="TextValueRestrictions" required="true" revision=""> <HSString name="restrictByValue" required="true" restrictType="1" xmlNodeType="1"> <restrictedValue>CA</restrictedValue> <restrictedValue>WA</restrictedValue> <restrictedValue>VA</restrictedValue> </HSString> <HSString name="restrictByRange" required="true" restrictType="2" xmlNodeType="1"> <restrictedValue>0</restrictedValue> <restrictedValue>100</restrictedValue> </HSString> <HSString name="restrictByRangeNoMIN" required="true" restrictType="2" xmlNodeType="1"> <restrictedValue /> <restrictedValue>500</restrictedValue> </HSString> <HSString name="restrictByRangeNoMAX" required="true" restrictType="2" xmlNodeType="1"> <restrictedValue>40</restrictedValue> <restrictedValue /> </HSString> <HSString name="restrictByPattern" required="true" restrictType="3" xmlNodeType="1"> <restrictedValue>^Pattern</restrictedValue> </HSString> </HSDataContainerType> <HSDataContainerType name="NumberValueRestrictions" required="true" revision=""> <HSInteger name="restrictByValue" required="true" restrictType="1" xmlNodeType="1"> <restrictedValue>10</restrictedValue> <restrictedValue>20</restrictedValue> <restrictedValue>30</restrictedValue> </HSInteger> <HSInteger name="restrictByRange" required="true" restrictType="3" xmlNodeType="1"> <restrictedValue /> </HSInteger> <HSInteger name="restrictByPattern" required="true" restrictType="3" xmlNodeType="1"> <restrictedValue>$1234</restrictedValue> </HSInteger> </HSDataContainerType> <HSDataContainerType name="OtherRestrictions" required="true" revision=""> </HSDataContainerType> <HSDataContainerType name="BinaryRestrictions" required="true" revision=""> </HSDataContainerType> </HSDataContainerType> <HSDocumentation> <shortDescription><![CDATA[ This is an example of a complex set of inputs. ]]></shortDescription> <descriptionSection title="myWebserviceDesc"><![CDATA[ My way or the highway. My way or the highway. My way or the highway. My way or the highway. My way or the highway. My way or the highway. My way or the highway. ]]></descriptionSection> <returnCodeDescription code="" /> </HSDocumentation> </HSContract> ---------------------------------------------------------------- -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Markus Abt Sent: Thursday, July 17, 2003 6:58 AM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: AW: [xsl] can't display heading in between fields...pls. help John, it's hard to help you without knowing the relevant structure of your XML input, and all relevant parts of your style sheet. 1. So I have to guess for the Input XML: - your XML tree contains only one <HSDataContainerType name="Inputs"> - your XML tree contains only one <HSDataContainerType name="Outputs"> - "Inputs" and "Outputs" are siblings, at least not contained in each other The XML part you posted in one of your recent mails contained only one "Outputs" and no "Inputs", so I can't tell, if the above is true. If it is true then it should be very simple to do. 2. For your XSL, I guess: What you are trying to do is: For every field type <HSString>, <HSDecimal>, <HSInteger>, etc.: - write a template which outputs the field properties. - if it is the first "Inputs" or "Outputs" field, regardless of the type, print the {In|Out}put Descriptions heading. This seems to be a complicated solution to me. You have to copy (or call) the code to do this in every type's template. Better: Your stylesheet contains some code which looks roughly like: <xsl:apply-templates select="HSDataContainerType"/> and which is responsible for processing the "Inputs" and "Outputs" Container Types. How does it look like in your stylesheet? (i.e. there may be a mode attribute) If you found it, change it to (roughly:) <h5><a name="in">Input Description</a></h5> <xsl:apply-templates select="HSDataContainerType[@name='Inputs']"/> <h5><a name="out">Output Description</a></h5> <xsl:apply-templates select="HSDataContainerType[@name='Outputs']"/> You can use your tests "[contains(@name, 'Inputs')]" if nescessary. You may also output the description headings only if there exist at least input/output field, resp. The easiest way to do this is write templates for HSDataContainerType[@name='***puts'] and put the heading there, but you may also do a simple <xsl:if test="HSDataContainerType[@name='***puts']"> around the above. The logic behind is: "Find the part in your XML input which corresponds to the wanted description heading on HTML output." This is not the first "Input" field. It is the <HSDataContainerType name="Inputs"> element. Hope this helps. I fear that I can't help you more without exact knowledge of your XML structure (see [1.] above) and all relevant parts of your stylesheet (not only the templates but also how they are applied or called). Regards, Markus __________________________ Markus Abt Comet Computer GmbH http://www.comet.de ---------- Von: John Liebermann Gesendet: Mittwoch, 16. Juli 2003 23:19 An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Betreff: [xsl] can't display heading in between fields...pls. help [...] The highlighted 'Output Description' above is displayed during all times where there is a <HSString> which has an ancestor 'Output'. I want this to be displayed ONLY once. So, what i can't figure out is how to be able to display a heading in between the descriptions (as marked on the output above). Thank you all for your help. Regards, John XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
AW: [xsl] can't display heading in , Markus Abt | Thread | AW: [xsl] can't display heading in , Markus Abt |
[xsl] Re: how to remove xalan exten, Dimitre Novatchev | Date | RE: [xsl] Combining XML with XLink , Américo Albuquerque |
Month |