[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL : template for attribute

Subject: XSL : template for attribute
From: "Chanukov Orit" <orit@xxxxxxxxxxxxxxx>
Date: Tue, 27 Apr 1999 16:49:02 +0200
xsl entity ref
Hello .
 
How should I write template for attribute ?
 
In my XML file I have , for example , the following line :
 
 <Field line="16" offset="1" colr="8" crlf="1" >Selection or command</Field>
 
crlf attribute should insert <&br> to the output .
Different nodes of XML  tree have this attribute ( not only Field ) .
 
in XSL file I wrote the following :
 
<xsl:template match="text()"><xsl:value-of /></xsl:template>
 
<xsl:template match="Field">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="@crlf">
    <br></br>
 </xsl:template>
 
It doesn't work .
What wrong here ?
See attached XML and XSL files .
 
Thanks in advance ,
Orit .
 
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
	<BODY STYLE="background-color:silver" xml:space="preserve" >
	<xsl:apply-templates select="Screen"/>
	</BODY>
</HTML>
</xsl:template>

  <xsl:template match="Screen">
    <p><H1 ><xsl:value-of select="Screen-ID/name"/></H1>

    <H1><xsl:value-of select="Title"/></H1></p>
      
	  <xsl:apply-templates />
  </xsl:template>


<xsl:template match="text()"><xsl:value-of /></xsl:template>

<xsl:template match="Field">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="Instruct">
<p>
<xsl:apply-templates />
</p>
</xsl:template>

<xsl:template match="Footer">
<p >
<xsl:apply-templates />
</p>
</xsl:template>


<xsl:template match="Menu">

  <xsl:for-each select="menu-item">
  <xsl:entity-ref name="nbsp"></xsl:entity-ref>
  <xsl:entity-ref name="nbsp"></xsl:entity-ref>
  <xsl:entity-ref name="nbsp"></xsl:entity-ref>
  <xsl:value-of select="caption"/>
  </xsl:for-each>

</xsl:template>

<xsl:template match="input">
<input >
	<xsl:attribute name="size">
	<xsl:value-of select="@len"/> 
	</xsl:attribute>
</input>
</xsl:template>

<xsl:template match="Function-Keys">
  <xsl:for-each select="function-item">
    <input type="button" >
  	 <xsl:attribute name="value">
  	  <xsl:value-of select="caption"/> 
  	  </xsl:attribute>
  	  <xsl:attribute name="name">
  	  <xsl:value-of select="caption"/> 
  	 </xsl:attribute>
    </input> 
  </xsl:for-each>
</xsl:template>

 <xsl:template match="@crlf">
    <br></br>
 </xsl:template>

<xsl:template match="@colr">
	<xsl:attribute name="STYLE">color :
	  <xsl:choose>
        <xsl:when test="@colr[.='2']">white</xsl:when >
        <xsl:when test="@colr[.='J']">blue</xsl:when >
        <xsl:when test="@colr[.='0']">green</xsl:when >
        <xsl:when test="@colr[.='9']">red</xsl:when >
        <xsl:when test="@colr[.='B']">yellow</xsl:when >
        <xsl:when test="@colr[.='H']">pink</xsl:when >
        <xsl:otherwise >black</xsl:otherwise >
	 </xsl:choose>
  	 </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>
<?xml version='1.0'?>
<?xml:stylesheet type="text/xsl" href="newpage4.xsl" ?>
<Screen xmlns:dt="urn:schemas-microsoft-com:datatypes" xml:space="preserve">
	<Screen-ID line="1" offset="2" attr="J">
		<name>MAIN</name>
		<id>1234567890</id>
	</Screen-ID>
	<Title line="1" offset="33" attr="0">AS/400 Main Menu</Title>
	<Field line="2" offset="50" attr="0">System:</Field>
	<Field line="2" offset="72" attr="0" crlf="1">S4440738</Field>
	<Instruct line="3" offset="2" attr="J">Select one of the following:</Instruct>
	<Menu line="5" offset="7" attr="0" >
		<menu-item line="5" offset="7" attr="0" crlf="1">
			<caption>1. User tasks</caption>
			<action>1[Enter]</action>
		</menu-item>
		<menu-item line="6" offset="7" attr="0" crlf="1">
			<caption>2. Office tasks</caption>
			<action>2[Enter]</action>
		</menu-item>
		<menu-item line="7" offset="7" attr="0" crlf="1">
			<caption>3. General system tasks</caption>
			<action>3[Enter]</action>
		</menu-item>
		<menu-item line="8" offset="7" attr="0" crlf="1">
			<caption>4. Files, libraries, and folders</caption>
			<action>4[Enter]</action>
		</menu-item>
		<menu-item line="9" offset="7" attr="0" crlf="1">
			<caption>6. Communications</caption>
			<action>6[Enter]</action>
		</menu-item>
		<menu-item line="10" offset="7" attr="0" crlf="1">
			<caption>7. Define or change the system</caption>
			<action>7[Enter]</action>
		</menu-item>
		<menu-item line="11" offset="7" attr="0" crlf="1">
			<caption>8. Problem handling</caption>
			<action>8[Enter]</action>
		</menu-item>
		<menu-item line="12" offset="7" attr="0" crlf="1">
			<caption>9. Display a menu</caption>
			<action>9[Enter]</action>
		</menu-item>
		<menu-item line="13" offset="7" attr="0" crlf="1" >
			<caption>10. Information Assistant options</caption>
			<action>10[Enter]</action>
		</menu-item>
		<menu-item line="14" offset="7" attr="0" crlf="1">
			<caption>11. Client Access tasks</caption>
			<action>11[Enter]</action>
		</menu-item>
		<menu-item line="15" offset="7" attr="0" crlf="1">
			<caption>90. Sign off</caption>
			<action>90[Enter]</action>
		</menu-item>
	</Menu>
	<Field line="16" offset="1" attr="8" crlf="1" >Selection or command</Field>
	<Field line="17" offset="1" >===&gt;</Field>
	<input line="17" offset="5" attr="2" len ="154" crlf="1"></input>
	<Function-Keys>
		<function-item>
			<caption>F3=Exit</caption>
			<action>[F3]</action>
		</function-item>
		<function-item>
			<caption>F4=Prompt</caption>
			<action>[F4]</action>
		</function-item>
		<function-item crlf="1">
			<caption>F9=Retrieve</caption>
			<action>[F9]</action>
		</function-item>
		<function-item>
			<caption>F12=Cancel</caption>
			<action>[F12]</action>
		</function-item>
		<function-item>
			<caption>F13=Information Assistant</caption>
			<action>[F13]</action>
		</function-item>
		<function-item crlf="1">
			<caption>F23=Set initial menu</caption>
			<action>[F23]</action>
		</function-item>	
	</Function-Keys>
	<Footer attr="0" crlf="1" >(C) COPYRIGHT IBM CORP. 1980, 1996. </Footer>
</Screen>
Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.