OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XML friendly runtime templating languages

[ Lists Home | Date Index | Thread Index ]
  • To: Robert Koberg <rob@koberg.com>
  • Subject: Re: [xml-dev] XML friendly runtime templating languages
  • From: "M. David Peterson" <m.david.x2x2x@gmail.com>
  • Date: Mon, 28 Mar 2005 21:40:30 -0700
  • Cc: XML Developers List <xml-dev@lists.xml.org>
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=a8X/7trmMqdeJDwHmMRUY4il6elcPnGW8BwF3kbLB/Bs0ADa2UZ5O7xK8j8jP9eZ4cEPf9sqsRiAAsHfXrNI/weZuYLPno6HpTvhd3hEDWz/SPJCWkKi2Oqj2tjzmczEOkke1o5TKsj/98cQ/Ooi6/7wyKkVzEfY5ly51Z9jVnc=
  • In-reply-to: <4248B15C.8050204@koberg.com>
  • References: <4248B15C.8050204@koberg.com>
  • Reply-to: "M. David Peterson" <m.david.x2x2x@gmail.com>

Hi Robert...

There are lots of different ways you can hack your XSLT to conform
more to your desired format but probably the easiest is simply:

<input>
<xsl:if test="boolean(@checked)">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>

Actually, the boolean function isnt even necessary. I put it there to
better represent the format you suggested.  In reality, no matter its
value (you can extend the test to check for this by simply adding '=
xyz' or whatever you may want to check for) if the checked attribute
exists the test will evaluate to true, if not, false and the contained
xsl:attribute element will not be added to the <input/> element.

Compared to your example obviously this is a lot more code to get the
same functionality but the fact that this will work and the desired
sample will not obviously presents a choice of verbosity over
verbosity/complexity instead of the desired choice of simplicity over
simplicity/verbosity.  Keep in mind that with XPath 2.0 this all
changes to give you exactly what it is you are looking for... well,
not the exact syntax but close enough to put a smile on your face for
sure.

Hope this helps!  BTW... You may find some more ideas over on XSL-List
> http://www.mulberrytech.com/xsl/xsl-list/index.html

Regards,

<M:D/>


On Mon, 28 Mar 2005 17:37:32 -0800, Robert Koberg <rob@koberg.com> wrote:
> Hi,
> 
> I recently did an app that pre-generated out to Jakarta Velocity
> templates. I chose Velocity because I thought it was the most XML
> friendly (and I have a java bias). I posted a minor annoyance about
> still having to do some redundant coding for SGML attribute minimazation
> brought into XML:
> 
> #set ($isChecked = $page.getBoolean("isChecked"))
> #if ($isChecked)
>    <input ... checked="checked"/>
> #else
>    <input .../>
> #end
> 
> I can't write something like:
> 
> <input ... #if($isChecked)checked="checked"#end/>
> 
> becuase the template code must exist in a well formed XML document to be
> used in an XSL transformation.
> 
> Andrew Clover clued me in to PXTL where (from the PXTL spec):
> 
> "If it is a conditional element, it is checked for success. If
> unsuccessful, the element is removed with all its child nodes. If
> successful, the element is replaced by its children."
> 
> Andrew responded to my post with:
> 
> "Well that's a failing of the templating language rather than XHTML as
> such. A templating language that aims at being helpful for XML should
> provide a mechanism for inclusion/exclusion of an attribute.
> 
> For example in PXTL:
> 
>    <input type="radio" checked="checked{?px_if isChecked?}"/>
> 
> *I was wondering if there are other runtime templating languages out
> there that I am missing.* I am not including XSLT for runtime processing
> because of its need to parse the XML source for each transformation.
> 
> best,
> -Rob
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 


-- 
<M:D/>

:: M. David Peterson ::
XML & XML Transformations, C#, .NET, and Functional Languages Specialist




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS