[BACK] Return to asHCard.xsl CVS log [TXT] [DIR] Up to [Public] / 2001 / palmagent

Annotation of 2001/palmagent/asHCard.xsl, revision 1.6

1.1 connolly 1: <xsl:transform
 2:   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 3:   version="1.0"
 4:   xmlns:h="http://www.w3.org/1999/xhtml"
 5:   xmlns:d='http://dev.w3.org/2001/palmagent/danger#'
 6:   xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
 7:   >
 8: 
1.4 connolly 9: <blockquote
 10:   xmlns="http://www.w3.org/1999/xhtml">
 11:  <h1>asHCard.xsl -- transform Danger contacts in RDF to hCard</h1>
 12: 
 13:  <p>See also: <a
 14:  href="http://developers.technorati.com/wiki/hCard">hCard</a>, <a
 15:  href="http://www.advogato.org/person/connolly/diary.html?start=26">Using
 16:  hCard, XSLT, and RDF to sync the family cellphones</a>, advogato
 17:  diary entry 26 Jun 2005</p>
 18: 
 19: <pre>
 20: $Log: asHCard.xsl,v $
1.6 ! connolly 21: Revision 1.5 2005年06月26日 22:03:00 connolly
 ! 22: - use real nickname property rather than additional-name
 ! 23:  (works with apple addressbook)
 ! 24: - fix UID code, partly
 ! 25: 
1.5 connolly 26: Revision 1.4 2005年06月26日 21:44:41 connolly
 27: cited some sources; moved log, Id from XML comments to XHTML
 28: 
1.4 connolly 29: Revision 1.3 2005年06月26日 21:36:52 connolly
 30: - handle email addresses (but not labels)
 31: - move category to end of entry
 32: 
 33: Revision 1.2 2005年06月26日 21:27:00 connolly
 34: - handle telephones, including converting labels to types
 35: - handle addresses
 36: - handle notes
 37: - handle nickname-only items
 38: - convert urls to XHTML (though not to vCard)
 39: - handle categories... one, anyway
 40: 
 41: Revision 1.1 2005年06月26日 20:46:27 connolly
 42: handles name (first, middle, last) and company
 43: </pre>
 44: 
 45: <address>
 46:  <a href="http://www.w3.org/People/Connolly/">Dan Connolly</a>
 47:  <br />
1.6 ! connolly 48:  <small>$Id: asHCard.xsl,v 1.5 2005年06月26日 22:03:00 connolly Exp $</small>
1.4 connolly 49: </address>
 50: </blockquote>
1.1 connolly 51: 
 52: <xsl:output method="xml" indent="yes" />
 53: 
 54: <xsl:param name="Category" select='"Medical"' />
 55: <xsl:param name="Base" select='"http://address.sidekick.dngr.com/show?contact_id="' />
 56: 
 57: 
 58: <xsl:template match="/">
 59:  <html
 60:   xmlns="http://www.w3.org/1999/xhtml">
 61:   <head><title>Contacts: <xsl:value-of select="$Category" /></title>
 62:   <!-- profile? -->
 63:   </head>
 64:   <body>
 65:    <h1>Contacts</h1>
 66:    <p>@@pointer to source? last update?</p>
1.4 connolly 67:    <address>converted from <em>some</em> contact.rdf using asHCard.xsl from <a href="http://dev.w3.org/cvsweb/2001/palmagent/">palmagent</a></address>
1.1 connolly 68: 
 69:    <!-- for each category... -->
 70:    <div>
 71:    <h2><xsl:value-of select="$Category" /></h2>
 72: 
 73:    <ul>
 74:     <xsl:apply-templates />
 75:    </ul>
 76:    </div>
 77:   </body>
 78:  </html>
 79: </xsl:template>
 80: 
 81: <xsl:template match="d:contact[d:category=$Category]">
 82:  <li class="vcard"
 83:   xmlns="http://www.w3.org/1999/xhtml"
1.5 connolly 84:   id='{@rdf:ID}'> <!-- umm... uids are global, no? @@-->
1.2 connolly 85: 
 86:   <!-- @@ last-modified -->
 87: 
 88:   <xsl:choose>
 89:    <xsl:when test="d:last_name or d:first_name">
 90:    <span class="n">
 91:     <span class="Family-Name"><xsl:value-of select="d:last_name" /></span>
 92:     <xsl:text>, </xsl:text>
 93:     <span class="Given-Name"><xsl:value-of select="d:first_name" /></span>
 94:     <xsl:if test="d:middle_name">
 95:      <xsl:text> </xsl:text>
 96:      <span class="Additional-Name"><xsl:value-of select="d:middle_name" /></span>
 97:     </xsl:if>
 98:     <xsl:if test="d:nick_name">
 99:      <xsl:text> </xsl:text>
1.5 connolly 100:      <em class="nickname"><xsl:value-of select="d:nick_name" /></em>
1.2 connolly 101:     </xsl:if>
 102:    </span>
 103:    </xsl:when>
 104: 
 105:    <xsl:when test="d:nick_name">
1.5 connolly 106:    <em class="n nickname"><xsl:value-of select="d:nick_name" /></em>
1.2 connolly 107:    </xsl:when>
 108:   </xsl:choose>
 109: 
1.1 connolly 110:   <xsl:if test="d:company">
 111:    <div class="org"><xsl:value-of select="d:company" /></div>
 112:   </xsl:if>
1.2 connolly 113: 
 114:   <xsl:if test="d:urls/d:urls_item">
 115:    <ul>
 116:    <xsl:for-each select="d:urls/d:urls_item">
1.6 ! connolly 117:     <li><a class="url" href="{d:address}"><xsl:value-of select="d:label" /></a></li>
 ! 118:     <!-- hmm... label gets lost in conversion to vCard -->
1.2 connolly 119:    </xsl:for-each>
 120:    </ul>
 121:   </xsl:if>
 122: 
 123:   <xsl:if test="d:addresses/d:addresses_item/*">
 124:    <ul>
 125:    <xsl:for-each select="d:addresses/d:addresses_item">
1.6 ! connolly 126:     <!--
 ! 127: The TYPE parameter values can include "dom" to
 ! 128:  indicate a domestic delivery address; "intl" to indicate an
 ! 129:  international delivery address; "postal" to indicate a postal
 ! 130:  delivery address; "parcel" to indicate a parcel delivery address;
 ! 131:  "home" to indicate a delivery address for a residence; "work" to
 ! 132:  indicate delivery address for a place of work; and "pref" to indicate
 ! 133:  the preferred delivery address when more than one address is
 ! 134:  specified. These type parameter values can be specified as a
 ! 135:  parameter list (i.e., "TYPE=dom;TYPE=postal") or as a value list
 ! 136:  (i.e., "TYPE=dom,postal"). This type is based on semantics of the
 ! 137:  X.520 geographical and postal addressing attributes. The default is
 ! 138:  "TYPE=intl,postal,parcel,work".
 ! 139:     -->
 ! 140: 
 ! 141:     <!-- darn... xhtml2vcard.xsl (Version 0.4.7 2005年06月22日)
 ! 142:        doesn't seem to grok ADR types -->
 ! 143:     <xsl:variable name="typ">
 ! 144:      <xsl:choose>
 ! 145:       <xsl:when test='d:label="Home"'>
 ! 146:        <xsl:text>intl postal parcel dom</xsl:text>
 ! 147:       </xsl:when>
 ! 148: 
 ! 149:       <xsl:when test='d:label="Work"'>
 ! 150:        <xsl:text>intl postal parcel work</xsl:text>
 ! 151:       </xsl:when>
 ! 152: 
 ! 153:       <xsl:when test='d:label="Unlabeled"'>
 ! 154:        <xsl:text>intl postal parcel work</xsl:text>
 ! 155:       </xsl:when>
 ! 156: 
 ! 157:       <xsl:otherwise>
 ! 158:        <xsl:message>unknown address number label: <xsl:value-of select="d:label" /></xsl:message>
 ! 159:       </xsl:otherwise>
 ! 160:      </xsl:choose>
 ! 161:     </xsl:variable>
 ! 162: 
 ! 163:     <li class="adr {$typ}">
1.2 connolly 164:      <div class="street-address"><xsl:value-of select="d:street" /></div>
 165:      <div>
 166:       <span class="locality"><xsl:value-of select="d:city" /></span>
 167:       <xsl:text>, </xsl:text>
 168:       <span class="region"><xsl:value-of select="d:state" /></span>
 169:       <xsl:text> </xsl:text>
 170:       <span class="postal-code"><xsl:value-of select="d:zip" /></span>
 171:      </div>
 172:     </li>
 173:    </xsl:for-each>
 174:    </ul>
 175:   </xsl:if>
 176: 
1.3 connolly 177:   <xsl:if test="d:email_addresses/d:email_addresses_item">
 178:    <ul>
 179:    <xsl:for-each select="d:email_addresses/d:email_addresses_item">
 180:     <li>
 181:      <xsl:value-of select="d:label" />
 182:      <xsl:text>: </xsl:text>
1.6 ! connolly 183:      <!-- xhtml2vcard seems to only grok email address types
 ! 184:         internet and pref :( -->
 ! 185:      <a class="email {d:label}" href="mailto:{d:address}">
1.3 connolly 186:       <xsl:value-of select="d:address" />
 187:      </a>
 188:     </li>
 189:    </xsl:for-each>
 190:    </ul>
 191:   </xsl:if>
 192: 
1.2 connolly 193:   <xsl:for-each select="d:phone_numbers/d:phone_numbers_item">
 194:    <xsl:variable name="num" select="d:number" />
 195: 
 196:    <!--
 197: 
 198:   The TYPE parameter values can include:
 199:  "home" to indicate a telephone number associated with a residence,
 200:  "msg" to indicate the telephone number has voice messaging support,
 201:  "work" to indicate a telephone number associated with a place of
 202:  work, "pref" to indicate a preferred-use telephone number, "voice" to
 203:  indicate a voice telephone number, "fax" to indicate a facsimile
 204:  telephone number, "cell" to indicate a cellular telephone number,
 205:  "video" to indicate a video conferencing telephone number, "pager" to
 206:  indicate a paging device telephone number, "bbs" to indicate a
 207:  bulletin board system telephone number, "modem" to indicate a MODEM
 208:  connected telephone number, "car" to indicate a car-phone telephone
 209:  number, "isdn" to indicate an ISDN service telephone number, "pcs" to
 210:  indicate a personal communication services telephone number. The
 211:  default type is "voice".
 212: 
 213:  http://www.ietf.org/rfc/rfc2426.txt
 214:    -->
 215:    <xsl:variable name="typ">
 216:    <xsl:choose>
 217:     <xsl:when test='d:label = "Home"'>
 218:      <xsl:text>home msg</xsl:text>
 219:     </xsl:when>
 220: 
 221:     <xsl:when test='d:label = "Work"'>
 222:      <xsl:text>work msg</xsl:text>
 223:     </xsl:when>
 224: 
 225:     <xsl:when test='d:label = "Mobile"'>
 226:      <xsl:text>cell msg</xsl:text>
 227:     </xsl:when>
 228: 
 229:     <xsl:when test='d:label = "Unlabeled"'>
 230:      <xsl:text>voice</xsl:text>
 231:     </xsl:when>
 232: 
 233:     <xsl:otherwise>
 234:       <xsl:message>unknown phone number label: <xsl:value-of select="d:label" /></xsl:message>
 235:     </xsl:otherwise>
 236:    </xsl:choose>
 237:    </xsl:variable>
 238: 
 239:    <div class="tel">
 240:    <xsl:value-of select="d:label" />
 241:    <xsl:text>: </xsl:text>
 242:    <!-- tel: URI needs formatting -->
 243:    <a class="{$typ}" href="tel:{$num}">
 244:     <xsl:value-of select="$num" />
 245:    </a>
 246:    </div>
 247:   </xsl:for-each>
 248: 
 249:   <xsl:if test="d:notes">
 250:    <blockquote class="note"><xsl:value-of select="d:notes" /></blockquote>
 251:   </xsl:if>
 252: 
1.3 connolly 253:   <xsl:if test="d:category">
 254:    <div><small class="categories">
 255:    <xsl:value-of select="d:category" />
 256:    </small></div>
 257:   </xsl:if>
1.1 connolly 258:  </li>
 259: </xsl:template>
 260: 
 261: <!-- don't pass text thru -->
 262: <xsl:template match="text()"></xsl:template>
 263: 
 264: </xsl:transform>

Webmaster

AltStyle によって変換されたページ (->オリジナル) /