Ejemplo n.º 1
0
<?php

////////////////////////////////////////////////////////////////////////////////
// Work     : (ml)Silkworm (xml example)
// Copyright: (c) 2013 Dodzi Y. Dzakuma (http://www.nexocentric.com)
//                See copyright at footer for more information.
// Version  : 1.00
////////////////////////////////////////////////////////////////////////////////
require_once "../Silkworm.php";
#-----------------------------------------------------------
# example 1 (completely manual - tedious, but has uses)
#-----------------------------------------------------------
$xmlDrinks = new Silkworm("xml");
//this sets silkworm to default to xml styles
$xmlDrinks->xmlVersion("1.0");
$xmlDrinks->drinks($xmlDrinks->cdata("This contains a lot of data about drinks that don't really matter."), $xmlDrinks->hot($xmlDrinks->alcohols($xmlDrinks->drink("wine"), $xmlDrinks->drink("coffee"), $xmlDrinks->drink("rum")), $xmlDrinks->teas($xmlDrinks->drink("green"), $xmlDrinks->drink("oolong"), $xmlDrinks->drink("white")), $xmlDrinks->coffees($xmlDrinks->drink("espresso"), $xmlDrinks->drink("milk"), $xmlDrinks->drink("black")), $xmlDrinks->juices($xmlDrinks->drink("apple"), $xmlDrinks->drink("orange"), $xmlDrinks->drink("tomato")), $xmlDrinks->sodas($xmlDrinks->drink("ginger ale"), $xmlDrinks->drink("apple hop"), $xmlDrinks->drink("caramel"))), $xmlDrinks->cold($xmlDrinks->alcohols($xmlDrinks->drink("vodka"), $xmlDrinks->drink("beer"), $xmlDrinks->drink("wine")), $xmlDrinks->teas($xmlDrinks->drink("green"), $xmlDrinks->drink("corn"), $xmlDrinks->drink("white")), $xmlDrinks->coffees($xmlDrinks->drink("frappuccino"), $xmlDrinks->drink("iced"), $xmlDrinks->drink("espresso")), $xmlDrinks->juices($xmlDrinks->drink("grapefruit"), $xmlDrinks->drink("apple"), $xmlDrinks->drink("orange")), $xmlDrinks->sodas($xmlDrinks->drink("cola"), $xmlDrinks->drink("root beer"), $xmlDrinks->drink("punch"))));
#-----------------------------------------------------------
# example 2 (just to reiterate on the modular example)
#-----------------------------------------------------------
$xmlData = new Silkworm("xml");
//this sets silkworm to default to xml styles
$xmlData->xmlVersion("1.0", array("encoding" => "utf-8"));
//XML version definition
$xmlData->doctype("HTML");
//doctype definition
#same object, different structure
$xmlData["novels"] = $xmlData->writtenMedia($xmlData->horror($xmlData->work("death"), $xmlData->work("pain"), $xmlData->work("suffering")), $xmlData->fantasy($xmlData->work("dragons"), $xmlData->work("magic"), $xmlData->work("fire wildthings")), $xmlData->scienceFiction($xmlData->work("L.A.S.E.R.s"), $xmlData->work("hyper warp"), $xmlData->work("time parameter")));
#same object, different structure
$xmlData["magazines"] = $xmlData->writtenMedia($xmlData->fashion($xmlData->work("shirts"), $xmlData->work("suits"), $xmlData->work("blouses")), $xmlData->tech($xmlData->work("gigakeys"), $xmlData->work("random access keyboards"), $xmlData->work("laundry and lint")), $xmlData->cooking($xmlData->work("vegetables"), $xmlData->work("bagels"), $xmlData->work("mexican")));
#same object, different structure
$xmlData["newspapers"] = $xmlData->writtenMedia($xmlData->local($xmlData->work("farmer bill"), $xmlData->work("effington daily"), $xmlData->work("high school")), $xmlData->national($xmlData->work("tabloid central"), $xmlData->work("politics the right way"), $xmlData->work("security and you")), $xmlData->scientific($xmlData->work("relativity"), $xmlData->work("obscurity"), $xmlData->work("obtuse")));