Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Newbie: Help with xml and xsl stylesheet

Reply
Thread Tools

Newbie: Help with xml and xsl stylesheet

 
 
no spam
Guest
Posts: n/a
 
      02-25-2004

Hi,

I am trying to build reusable templates for user input forms, and then
just use XSL to generate the forms...but I cannot get my xsl to match
any templates, and the output is fine.

here is my xml in full:
>>>> XML FILE >>>

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl"
href="http://lxsjfk1is1/ssrinterface/devutils/myform.xsl"?>

<fields>
<field>
<name>lAccount_Num</name>
<caption>Account Number:</caption>
<type>label</type>
<size></size>
<style>LEFT: 17px; WIDTH: 112px; POSITION: absolute; TOP: 13px;
HEIGHT: 18px</style>
<FOR>tAccount_Num</FOR>
<maxLength></maxLength>
<value/>
</field>
<field>
<name>tAccount_Num</name>
<caption></caption>
<type>Text</type>
<size></size>
<style>FONT-SIZE: xx-small; LEFT: 127px; WIDTH: 165px; POSITION:
absolute; TOP: 13px; HEIGHT: 18px</style>
<FOR></FOR>
<maxLength>15</maxLength>
<value/>
</field>
<field>
<name>tCRY</name>
<caption></caption>
<type>Text</type>
<size></size>
<style>FONT-SIZE: xx-small; LEFT: 400px; WIDTH: 50px; POSITION:
absolute; TOP: 13px; HEIGHT: 18px</style>
<FOR></FOR>
<maxLength>3</maxLength>
<value/>
</field>
<field>
<name>lCRY</name>
<caption>Currency:</caption>
<type>label</type>
<size></size>
<style>LEFT: 330px; WIDTH: 120px; POSITION: absolute; TOP: 13px;
HEIGHT: 18px</style>
<FOR>tCRY</FOR>
<maxLength>3</maxLength>
<value/>
</field>
<field>
<name>lAccount_Name</name>
<caption>Account Name:</caption>
<type>label</type>
<size></size>
<style>LEFT: 17px; WIDTH: 108px; POSITION: absolute; TOP: 40px;
HEIGHT: 18px</style>
<FOR>tAccount_Num</FOR>
<maxLength></maxLength>
<value/>
</field>
<field>
<name>tAccount_Name</name>
<caption></caption>
<type>Text</type>
<size></size>
<style>FONT-SIZE: xx-small; LEFT: 127px; WIDTH: 325px; POSITION:
absolute; TOP: 40px; HEIGHT: 18px</style>
<FOR></FOR>
<maxLength>75</maxLength>
<value/>
</field>
<field>
<name>lbranch_code</name>
<caption>Branch Code:</caption>
<type>label</type>
<size></size>
<style>LEFT: 17px; WIDTH: 112px; POSITION: absolute; TOP: 80px;
HEIGHT: 18px</style>
<FOR>tbranch_code</FOR>
<maxLength></maxLength>
<value/>
</field>
<field>
<name>tbranch_code</name>
<caption>Branch Code</caption>
<type>Text</type>
<size></size>
<style>FONT-SIZE: xx-small; LEFT: 127px; WIDTH: 135px; POSITION:
absolute; TOP: 80px; HEIGHT: 18px</style>
<FOR></FOR>
<maxLength>8</maxLength>
<value/>
</field>
<field>
<name>lEnabled</name>
<caption>Enabled:</caption>
<type>label</type>
<size></size>
<style>LEFT: 330px; WIDTH: 120px; POSITION: absolute; TOP: 80px;
HEIGHT: 18px</style>
<FOR>chEnable</FOR>
<maxLength></maxLength>
<value/>
</field>

<field>
<name>chEnable</name>
<caption></caption>
<type>Checkbox</type>
<size></size>
<style>LEFT: 402px; WIDTH: 16px; POSITION: absolute; TOP: 80px;
HEIGHT: 22px</style>
<FOR></FOR>
<maxLength></maxLength>
<value/>
</field>
</fields>
</xml>

<<< END OF XML <<<

and here is my XSL file in full:

>>> XSL Stylesheet >>>


<?xml version="1.0"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="field">

<xsl:choose>

<xsl:when match=".[type='Text']">
<input type="text">
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>

<xsl:if test=".[width!='']">
<xsl:attribute name="maxlength">
<xsl:value-of select="width"/>
</xsl:attribute>
</xsl:if>

</input>
</xsl:when>

<xsl:when match=".[type='label']">

<label>
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>

<xsl:attribute for="FOR">
<xsl:value-of select="for"/>
</xsl:attribute>

<xsl:attribute for="style">
<xsl:value-of select="style"/>
</xsl:attribute>

<xsl:if test=".[maxlength!='']">
<xsl:attribute name="maxlength">
<xsl:value-of select="maxlength"/>
</xsl:attribute>
</xsl:if>

<xsl:if test=".[size!='']">
<xsl:attribute name="size">
<xsl:value-of select="size"/>
</xsl:attribute>
</xsl:if>

<!-- CAPTION for Label -->
<xsl:value-of select="caption"/>
</label>

</xsl:when>

<xsl:when match=".[type='Checkbox']">
<input type="checkbox">
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>

<xsl:attribute for="style">
<xsl:value-of select="style"/>
</xsl:attribute>

</input>
</xsl:when>

</xsl:choose>

</xsl:template>
</xsl:stylesheet>

<<<< END OF XSL <<<<

both validate fine using MS XML4 Processor...using IE 6 on Windows 2000.

please point me in the right direction, thanks

Philip


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      02-25-2004
In article <403c6f69$0$198$(E-Mail Removed)>,
no spam <(E-Mail Removed)> wrote:

% I am trying to build reusable templates for user input forms, and then
% just use XSL to generate the forms...but I cannot get my xsl to match
% any templates, and the output is fine.

If the output is fine, what is the trouble?

% <xsl:when match=".[type='Text']">

This should be

<xsl:when test=".[type='Text']">

or you could have

<xsl:when test="type='Text'">

I would be inclined to create several small templates rather than one
template with a choose in it

<xsl:template match="field[type='Text']">
<input type="text" name="{name}">

<xsl:if test="width!=''">
<xsl:attribute name="maxlength">
<xsl:value-of select="width"/>
</xsl:attribute>
</xsl:if>

</input>
</xsl:template>


--

Patrick TJ McPhee
East York Canada
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use output of XSL transformation as new XSL stylesheet barney.b@iname.com XML 0 01-16-2006 02:29 PM
xml:stylesheet use in document with multiple stylesheet options David Blickstein XML 3 08-02-2005 03:10 PM
[XSL] : use array variable in XSL stylesheet MC XML 1 03-24-2005 10:41 AM
Documenting xsl (searching xsl:doc stylesheet) Thomas Sommer XML 0 11-25-2004 01:03 AM
have a stylesheet generate another stylesheet based on XML? Steven An XML 1 11-23-2004 01:07 PM



Advertisments