Hub Nexus
작가아직 작성자가 없습니다맡기

개선할 점이 보이나요? 변경을 제안하세요.

후원

매거진 XForms · 137개 중 107번째 페이지

Motivation

You want to dynamically load and render SVG.

Sample Program

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:svg="http://www.w3.org/2000/svg">;
<head>
<title>SVG Browser</title>
<style type="text/css">
#svgimg .xforms-value {
width: 400px;
min-width: 400px;
height: 400px;
min-height: 400px;
}
</style>
<xf:model>
<xf:instance id="current">
<current xmlns=""/>
</xf:instance>
<xf:instance id="names">
<names xmlns="">
<name fname="mozilla.svg">Mozilla</name>
<name fname="wii.svg">Wii</name>
<name fname="duke.svg">Duke</name>
<name fname="git.svg">Git</name>
<name fname="cartman.svg">Cartman</name>
<name fname="tiger.svg">Tiger</name>
<name fname="gcheck.svg">GCheck</name>
<name fname="pencil.svg">Pencil</name>
<name fname="python.svg">Python</name>
<name fname="ietf.svg">IETF</name>
<name fname="osgr_pie.svg">OSGR Pie</name>
</names>
</xf:instance>
<xf:instance id="inlinesvg">
<svg xmlns='http://www.w3.org/2000/svg'/>;
</xf:instance>
<xf:submission id="loadsvg"
method="get"
replace="instance"
instance="inlinesvg"
serialization="none"
mode="synchronous">
<xf:resource value="concat('svg/',.)"/>
</xf:submission>

<xf:action ev:event="xforms-ready">
<xf:setvalue ref="." value="instance('names')/name[1]/@fname"/>
<xf:send submission="loadsvg"/>
</xf:action>
</xf:model>
</head>
<body>
<h1>SVG Browser</h1>
<xf:select1 ref="." appearance="minimal" incremental="true">
<xf:label>Select SVG: </xf:label>
<xf:itemset nodeset="instance('names')/name">
<xf:label ref="."/>
<xf:value ref="@fname"/>
</xf:itemset>
<xf:send ev:event="xforms-value-changed" submission="loadsvg"/>
</xf:select1>

<xf:trigger>
<xf:label>Next</xf:label>
<xf:setvalue ev:event="DOMActivate"
ref="."
value="if(
instance('names')/name[
preceding-sibling::name[1]/@fname
= current()
],
instance('names')/name[
preceding-sibling::name[1]/@fname
= current()
]/@fname,
instance('names')/name[1]/@fname)"/>
</xf:trigger>

<br/>
<xf:output id="svgimg"
value="xf:serialize(instance('inlinesvg'))"
mediatype="image/svg+xml"/>
</body>
</html>

Credits

This was created by Alain Couthures on the XSLTForms mailing list. A working copy can currently be found on the AgenceXML web site.

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

이 페이지가 속한 매거진XForms

언어English

이용 허락: CC BY-SA 4.0 · 출처 en.wikibooks.org

1

0

0

0

Spinner Logo

코멘트

Spinner Logo
버전: 2CC0 1.0 — public domain
The runaway star that left the Tarantula Nebula
버전: 2CC0 1.0 — public domain
The Blackwell School, where segregation had no law behind it
버전: 2CC0 1.0 — public domain
The Eagle Nebula, seen in the infrared
버전: 2CC0 1.0 — public domain
The house where the Equal Rights Amendment was written
버전: 2CC0 1.0 — public domain
The Aleutians, the forgotten front of the Second World War
버전: 2CC0 1.0 — public domain
The Cosmic Cliffs are not cliffs