ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: nico <nicolas.marsgui@libertysurf.fr>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: Write once layout everwhere (?)
Date: Mon, 11 Jun 2007 21:35:52 +0200	[thread overview]
Message-ID: <opttrvd2rn9niby6@localhost> (raw)
In-Reply-To: <20070611114223.uig799728080wows@web.mail.umich.edu>

[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]

On Mon, 11 Jun 2007 11:42:23 -0400, Aditya Mahajan <adityam@umich.edu>  
wrote:

> Thanks. I had not looked at them and some of the things about handling
> at the ConTeXt end are more clear now. But I think that I did not
> explain my question correctly.
>
> What I do not understand how are abbreviations etc. handled by xslt for
> conversion into html. For example, how do I write an xsl style sheet
> that converts this xml input
>
> <abbreviation value="EECS", short="EECS", full="Electrical Engineering
> and Computer Science" />
>
> <p> I study <abbrev value="EECS"> which stands for <abbrev
> value="EECS", infull="yes"> </p>
>
> into html as
>
> <p> I study EECS which stands for Electrical Engineering and Computer
> Science </p>
>
> I know that this is not the right list to ask this sort of questions,
> but I am hoping that there are xml users here and they will be able to
> point me to the right direction.

I haven't followed the thread, but attached an idea of doing what you want  
with XSLT. Note that your example is not valid at all (commas between  
attributes, missing ending '/' for empty elements). BTW, it's not a good  
idea to use the same attribute ("value") as an reference identifier, and  
for referencing to another element.

Regards,

[-- Attachment #2: myxsl.xsl --]
[-- Type: application/octet-stream, Size: 1063 bytes --]

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

<xsl:output method="html" encoding="UTF-8" indent="yes"/>

<xsl:template match="abbrev">
  <xsl:variable name="abbrev" select="//abbreviation[@value=current()/@value]"/>
  <xsl:if test="$abbrev">
    <xsl:apply-templates select="$abbrev" mode="short"/>
  </xsl:if>
</xsl:template>

<xsl:template match="abbrev[@infull='yes']">
  <xsl:variable name="abbrev" select="//abbreviation[@value=current()/@value]"/>
  <xsl:if test="$abbrev">
    <xsl:apply-templates select="$abbrev" mode="full"/>
  </xsl:if>
</xsl:template>

<xsl:template match="abbreviation"/>

<xsl:template match="abbreviation" mode="full">
  <xsl:value-of select="@full"/>
</xsl:template>

<xsl:template match="abbreviation" mode="short">
  <xsl:value-of select="@short"/>
</xsl:template>

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

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

</xsl:stylesheet>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: myfile.xml --]
[-- Type: text/xml; name=myfile.xml, Size: 228 bytes --]

<body>
<abbreviation value="EECS" short="EECS"
              full="Electrical Engineering and Computer Science" />
 
<p> I study <abbrev value="EECS"/> which stands for <abbrev 
value="EECS" infull="yes"/> </p>

</body>

[-- Attachment #4: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2007-06-11 19:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-10 22:31 Pepe Barbe
2007-06-11  3:49 ` Aditya Mahajan
2007-06-11  5:16   ` luigi scarso
2007-06-11 12:26   ` John R. Culleton
2007-06-11 13:15     ` Aditya Mahajan
2007-06-11 12:26   ` Thomas A. Schmitz
2007-06-11 13:09     ` Aditya Mahajan
2007-06-11 13:34       ` Wolfgang Schuster
2007-06-11 15:42         ` Aditya Mahajan
2007-06-11 19:35           ` nico [this message]
2007-06-11 20:19             ` Aditya Mahajan
2007-06-11 20:28 ` nico
     [not found] <mailman.429.1181527849.2368.ntg-context@ntg.nl>
2007-06-11 10:46 ` Duncan Hothersall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=opttrvd2rn9niby6@localhost \
    --to=nicolas.marsgui@libertysurf.fr \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).