Sp Top Game Engineering
Sp Top Game Engineering CS 486
Popular in Course
Popular in ComputerScienence
verified elite notetaker
This 107 page Class Notes was uploaded by Michele Herzog on Thursday October 29, 2015. The Class Notes belongs to CS 486 at University of San Francisco taught by Staff in Fall. Since its upload, it has received 145 views. For similar materials see /class/231246/cs-486-university-of-san-francisco in ComputerScienence at University of San Francisco.
Reviews for Sp Top Game Engineering
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/29/15
Software Agents and Electronic Commerce CS48623 Payment and Exchange 2 Chris Brooks Department of Computer Science University of San Francisco 230 Introduction 0 Currentday payment systems credit cards PayPal etc are sufficient for some needs but lacking for others 0 Hard to deal with small payments 0 Setup required 0 Can t be easily liquidated 0 What other solutions are possible 231 Past Failures 0 The ecommerce landscape is littered with failed payment schemes Many of these ideas looked appealing but failed to catch on Some had technical problems Others were unable to get a market foothold Examining these systems can be instructive 232 Micropayments 0 One impediment to electronic commerce is the inability to pay small amounts for an item 0 For example you might be willing to pay a penny to read an article or 10 cents to watch a video 0 Standard payment mechanisms can t handle this 0 The transaction costs are larger than the amount being exchanged 0 A mechanism is needed to allow people to pay small amounts of money for an item 233 Markets for Micropayments 0 Potential markets for micropayments include 0 Songs 0 Articles 0 Images Comic Strips Stock Quotes Book pages 0 Games 234 unallenges In Implementlng Micropayments 0 There are a number of difficult technical problems to solve in implementing micropayments including 0 small transaction costs 0 Fast turnaround 1 second or less 0 Customer service A customer service call can cost a firm several dollars or more 235 CyberCoin 0 CyberCoin was an early attempt at micropayment 0 Users load an acocunt with a balance 39 Payments are then deducted from that account 0 Banks and credit card companies removed from theloop 39 System optimized to limit number of messages and crypto operations Smallvalue transactions can be protected with weaker encryption 236 CyberCoin CyberCoin used assured delivery to reduce customer service expenses and implement nonrepudiation Encrypted information is sent to user by merchant User s system sends payment to merchant Merchant fonNards information and key to CyberCoin CyberCoin processes payment and fonNards key to customer Both sides have protection from fraud and failure 237 CyberCoin 0 Why did CyberCoin fail according to cofounder Steve Crocker 0 Too much overhead for customers 0 Multiple authentication screens 0 Need to load an account ahead of time 0 No critical mass of merchants 0 Pricing alternatives emerged 0 Subscriptions 0 Advertising 233 CyberCoin 0 Subscriptions are appealing to sellers guaranteed income 0 Easier to predict demand 0 Problem Subscriptions work best for highvalue content 0 Ads have also proved to be very successful so far 0 The small amount a good is worth is charged to the advertiser 0 But advertisers prefer volume 0 May not be appropriate for small sellers 0 Web Ad revenue has declined for at least seven quarters 239 Millicent 0 Millicent was another micropayment protocol Proposed by DEC Millicent uses a cash substitute known as scrip Only valid with particular merchants Purpose avoid doublespending without expensive transactions or encryption 2310 Millicent How it works 0 User gets an account with a scrip broker 0 User wants to buy something from a vendor 0 The scrip broker issues scrip for a particular vendor 0 User then spends that scrip 2311 Millicent How it works 0 More detail 0 A piece of scrip consists of 0 Vendor ID Expiration Date Value 0 Consumer information for taxes discounts etc The above part is referred to as the Info Session ID 0 Session key 0 The session ID contains a unique session number 2312 Millicent How it works 0 The vendor stores a secret Xsesion number 0 X depends only on session number highorder bits for example 0 Session key is the MD5 hash of session ID concatenated with X 0 A Coin is a string with a value a serial number and a key 0 A Coin key is the Hash of Session ID Info Coin Xseria 2313 Millicent How it works 0 A customer gets vendor scrip from a broker 0 This scrip contains SessionlD Coin Coin key and session key 0 Customer sends SessionlD Coin Info and Coin key to vendor 0 Vendor can verify that the Coin key is valid by hashing the Coin 0 Customer doesn t know the secret X function so can t create scrip 0 If Vendor and broker use different X functions vendor can prevent the broker from colluding with the customer and changing the scrip value 0 Hashing is a very fast operation 2314 Millicent Current status Early promise but abandoned by Digital in 1999 Trial systems being tested in Japan Research projects based on Millicent are ongoing Main challenges 0 Infrastructure Vendor adoption Digital s economic health 2315 Netbill 0 Developed as an online payment system that would allow 0 Atomic payment and delivery Anonymity of customers 0 Ability for customers to prove group membership for discounts etc 0 Developed at Carnegie Mellon Later acquired by CyberCash and Visa 2316 Netbill How it works 0 Again digital goods are sent in encrypted form 0 Customer receives decryption key only after payment 0 Netbill server acts as a trusted intermediary so that identity can be hidden from the merchant 0 Publickey encryption is used in the standard way to prove authenticity of goods and nonrepudiation 2317 Netbill Status Still has promise but there are difficult challenges to widespread adoption Scaling group membership databases to large number of vendors in a consistent way is difficult Standardization across issuers and vendors is a chaHenge How to get everyone to agree on what a student is for example Transactions can require many messages to be sent Netbill is essentially at the promising research application stage largescale industry backing will be needed to allow it to be adopted of a wide scale 2313 More recent systems 0 A common recent idea is accumulating balance systems 0 You make a number of smaller purchases which are aggregated 0 You re then charged once for the balance 0 Number of transactions are reduced 2319 PepperCoin 0 Founded by Ron Rivest RSA and Silvio Micali zeroknowledge proof 0 Yet another cryptographic delivery system 0 Uses selective sampling of payments 0 A small fraction 8 of the micropayments are selected for processing 0 Each of these users are charged times their actual payment 0 Other payments are thrown away 2320 PepperCoin 0 In expectation everyone pays the same amount 0 But the number of transactions is greatly reduced 0 User fairness can be added by having consumers number their transactions 0 When a transaction is selected for payment at most that number of payments are charged 0 Bank assumes some risk here 0 Recently created a company not yet generally available 2321 Conclusions 0 Most people agree that more flexible payment mechanisms are needed 0 Low transaction costs Anonymity walkup little setup needed 0 Difficult to get a critical mass 0 Backing of large industry players needed Software Agents and Electronic Commerce CS48622 Payment and Exchange Chris Brooks Department of Computer Science University of San Francisco 220 Introduction 0 Payment and exchange is the third aspect of an ecommerce transaction 0 You ve found what you want discovery 0 and agreed to prices and terms negotiation 0 Now how to transfer everything 221 Challenges 0 There are lots of challenges for online payment including 0 Security Atomicity Speed Ease of Use Cost 0 and many more 222 Brickandmortar payment methods 0 Cash 0 Universal easy difficult to trace not secure 0 Can be easily converted into other forms Easily divided anonymous Works best for small transactions No recourse for fraud 223 Brickandmortar payment methods 0 Checks 0 Less universal relatively easy and secure 0 Some float can take several days for a check to clear Require a third party 0 Money orders cashiers checks travelers checks reduce risk Upfront payment guaranteed by check issuer Work like cash without anonymity 224 Brickandmortar payment methods 0 Credit Cards 0 Third party guarantees payment to seller 0 Very secure authorization neededhard to use in P2P Merchants must pay a fee 0 Consumers can refute transactions 225 Brickandmortar payment methods 0 Debit Cards 0 a form of stored value system Unlike credit cards deducts from a bank account Can be tied into a credit card Similiar issues to credit cards less universal 0 Fewer fraud protections 226 ueslraole bnaraCIerlSIlCS TOI39 Payment Systems 0 Easily exchanged Can be converted into some other payment mechanism 0 eg Money orders but not BART tickets 0 Portable 0 Can be used from any location 0 Secure theft eavesdropping tampering 0 Can prevent unauthorized use 227 uesiraoie onaracrensucs ror Payment Systems 0 Easy to Use 0 Tamperresistant 0 Hard to forge doublespend tamper 0 Divisible 0 One large denomination can be exchanged for several smaller demoninations 0 eg cash but not coupons or vouchers 223 ueslraole onaractensucs TOI39 Payment Systems 0 Hardware independent 0 No specialpurpose equipment needed for buyer or seller 0 Storable Can be retrieved remotely accrue interest add stability 0 Accounts needed 0 Can limit universal access 0 Network effects 0 Widely available and adopted Chickenandegg problem here 229 Utner porenuau cnaracrerlsucs of Payment Systems 0 Anonymity 0 Efficency 0 Fast transaction processing Lowcost processing 0 Transparent to user 0 Interest float who gets it 2210 Current Systems Credit cards Currently very popular 17 trillion per year 95 of online transactions 47 billion in US Less popular elsewhere 50 outside of US Merchant pays a transaction fee 0 This is a percentage of the sale 0 Split between merchant s bank cardholder association Visa and transaction processing agenCIes 0 Typically between 15 and 35 0 Rate depends on volume risk number of chargebacks 2211 Current Systems Credit cards 0 Advantages Ease of use widespread acceptance 0 Buyer is insured against theft 0 Relatively portable 0 Disadvantages 0 Lowcost items receive a higher rate Bank s processing cost is same for large and small transactions 0 ln online transactions the merchant never sees the card This makes disputed charges more of a problem 0 Can cost merchant up to 5 for a transaction 0 Purchases easily tracked 2212 Current Systems Credit cards 0 Steps of a credit card transaction 1 2 3 Customer sends info to merchant typically via SSL Merchant contacts a clearinghouse who acts as an intermediary Clearinghouse contacts bank to verify account info Bank credits merchant s account a few days later bank bills customer at the end of the month 2213 Current Systems Credit cards 0 Are they a good payment mechanism for ecommerce Sometimes Work fine for relatively large BZC purchases 0 Merchant expected to assume risk both for payment and fraud 0 Issues with setup time anonymity fungibility 0 Not everyone has a credit card especially juvenHes 2214 Current Systems Smart cards 0 User has a card that either encodes an amount on it or identifies them to a larger system 0 Card is tied to a store of currency 0 Example Dons dollars American Express 0 Cards can be contact or contactless 0 Contact Requires physical contact with a card reader Smart cards gift cards 0 Contactless A remote reader can process the card EZPass 2215 Current Systems Smart cards 0 Advantages easy mostly secure fast 0 Can be integrated into credit card systems AmEx Blue 0 Disadvantages Specialized equipment needed typically cannot be reconverted into cash or other payment systems 2216 Current Systems PayPal 0 Users create an account with PayPal and place funds in that account 0 These funds can then be freely transferred to other accounts to handle payment 0 Works for payments between individuals or businesses 0 Can also accept credit card transactions for a fee 0 Over 9 million users in 2001 0 Recently acquired by eBay 2217 Current Systems PayPal 0 Advantages Easy to use can transfer funds between individuals and businesses 0 Can deal with small amounts Allows individuals to accept credit cards 0 Disadvantages 0 Account required must put in cash in advance Relatively high levels of credit card fraud requires authorization for purchases over 200 0 Issue What is PayPal s revenue model 2213 Current Systems RocketCash 0 Like PayPal Rocketcash allows you to store value in an account 0 This can then be used for online purchases 0 Aimed at teens without credit cards 0 A subsidiary of Cocacola 39 Rocketcash given away with Coke Sprite Nestle etc Can be used to buy items from online vendors 2219 current oysrems Yahoo PayDirect 0 Users can route money from their personal checking account or from a PayDirect account 0 Professional users can accept credit cards for a fee 0 Users can have funds transferred into their account by other parties 0 Similiar to PayPaI 2220 Concepts Digital Wallets 0 The idea of a digital wallet is a hot ecommerce topic 0 Provides a wrapper for your credit card and other personal information 0 You register your information with a single provider 0 This provider then handles Authentication and privacy 0 Payment processing Bill management 0 Loyalty programs Micropayment aggregation 2221 Concepts Digital Wallets 0 Example Microsoft NET Passport 0 Uses Web Services 39 Single emailpassword for registration with all participating merchants 0 Transfer of sensitive information handled by Microsoft 0 Users don t need to worry about proliferation of sensitive information 0 User information also collected 0 Kids Wallet allows parents to specify where children can purchase 2222 Escrow services 0 For highvalue items buyer and seller might want guarantees of payment quality authenticity etc An escrow service manages this risk Buyer sends payment to the escrow service who notifies seller that payment has been received Seller sends goods to buyer Buyer accepts goods Payment transferred to seller minus a fee 2223 Escrow services 0 What if the buyer isn t happy 0 Buyer returns merchandise 0 Buyer s money returned 0 Escrow service may also help negotiate disputes for example over shipping charges Notes on XML March 5 2003 1 Intro XML is a language for describing data In fact it s not really a language but more like a metalanguagei That is a set of rules for describing how to build a language Even though it looks a lot like HTML they are quite different In HTML a tag like ltbgt hello ltbgt has a clear meaning make 7hello7 boldface ln XML a tag like ltauthorgtTolkienltauthorgt does not have a set interpre tation or semantics instead the meaning of the author tag is de ned by the XML document itself This can seem confusing but some examples will help make it clear ltxml versionquot1 Oquotgt ltbookgt ltauthorgt J RR Tolkien ltauthorgt lttitlegt The Lord of the Rings lttitlegt ltvolumesgt ltvolumegt Fellowship of The Ring ltvolumegt ltvolumegt The Two Towers ltvolumegt ltvolumegt Return of the King ltvolumegt ltvolumesgt ltpricegt 1495 ltpricegt ltpublishergt Ballantine ltpublishergt ltisbngt 0345340426 ltisbngt ltbookgt This simple XML document describes the book the Lord of the Rings The document has two components tags and content The content is the data in our document the author title and so on The tags are metadatai That is data about data They serve to help an application make sense of the data In this limited sense HTML tags also do this the tags in ltbgt hello ltbgt just indicate that 7hello7 should receive a particular sort of treatment XML requires that every opening tag eigi ltvolumegt have a correspond ing closing tag ltvolumegti Everything between an opening and closing tag including the content and the tags is called an element For example ltvolumegt Return of The King ltvolumegt is an element as is everything between ltvolumesgt and ltvolumesgt inclusive as is everything between ltbookgt and ltbookgti Notice that elements must be nested for example ltelement1gt ltelement2gt lt el ement 1gt is legal XML Whereas ltelement1gt ltelement2gt content ltelement 1gt ltelement2gt is not It can help to think of elements as a scope much like the scoping operators in a programming language In this case element2 begins Within the scope of elementl and so element has to end before elementl ends Tags must begin With a letter and can contain all the same characters as Java variables letters numbers underscore etc No spaces This regular structure allows us to construct a tree representing an XML document this Will prove to be very useful in parsing and analyzing XML for example our Tolkien doc looks like I author gt tolkien I I I volumel gt fellowship of the Ring I volumes I volume2 gt The Two Towers book I I volume3 gt The Return of the King I Publisher gt Ballantine isbn gt 0345340426 The top element book is referred to as the root element or the document element The tags are referred to as nodes just like normal tree terminology and the content is stored at the leaves 2 More on elements Sometimes an element has no content just a tag For example ltbookgt ltauthorgt Tolkien ltauthorgt ltcoauthorgt ltcoauthorgt ltbookgt This is called an empty element Therels a shorthand for this we can write ltcoauthor gt instead the space before 77 is not essential but makes it easier to read Element tags can also contain attributes and values this is useful if you want to specify that an object belongs to one of a few types For examp e ltbook genrequotfantasyquot sizequot1argequot gt ltbookgt Note that the values are enclosed in double quotes you can also use single quotes in case your value has a 77 character in it i The decision whether to use attributes and values or subelements is largely a stylistic one typically if an variable can only take on one of a few values an attri ute makes sense lft e number of genres is large or will be extensible a subelement makes more sense Also order is preserved for subelements whereas attributes and values get treated like a hash table In general pa rameters of an element should be treated as attributes whereas features of an element should be treated as subelements Most of the rules you7ve learned for objectoriented design apply here ltbookgt ltgenregtfantasy ltgenregt ltbookgt Is also valid A particularly useful attribute is the ID tag this lets you assign a unique identi er to an e ement and then refer back to it later in the XML document for example ltvolume idquotbook1quotgt Fellowship of the Ring ltvolumegt ltvolume idquotbook2quotgt The Two Towers Read this book after you ve finished ltvolumeref idrefquotbook1 gtltvolumegt Here we used the ref tag to refer to a previous volume we provide the XML parser with the information that this is a reference to a volume and give it the unique id Notice that this is an empty element so we close it with i 3 Document Prolog An XML document begins with a header known as a document prolog which identi es that the document is in XML and points to de nitions of the allowable tagsi Here s an example of a document prolog quot ltENTITY jrrt quotJRR Tolkienquotgt lt ENTITY elvishkey quotelvish Xm1quotgt gt We can decompose this into parts The rst line is the XML declaration It indicates that the document is XML the version 10 is the only version to date the encoding ASCII is default if you use a nonEnglish character set you would indicate it here and whether the document is standalone or whether an extra document usually a DTD more on that in a bit is needed The second line is called the document type declaration it just says what the type of the root element is in this case book This lets the XML processor know what sort of XML document it will be dealing with Following this are two lines that designate a document type de nition DTD A DTD describes how a particular XML document is laid out for example what elements a book can have what elements are subelements of other elements what values an attribute can have and so on Its like a grammar The rst line indicates the type of DTD to use and its encodingi The second is a URL that tells the XML processor where to nd this DTDi More on DTDs in a bit The nal bit is what s called the internal subset these are basically addi tional de nitions on top of those speci ed in the DTDi They7re called entitiesi They re very similar to macros in C we7ll talk more about them belowi All of the lines in the prolog except for the rst are optional the basre minimum that a le must have is ltxm1 versionquot10quotgt 4 Namespaces Sometimes you7ll want to use more than one DTD within an XML document for example say you have a DTD describing books and a DTD describing people In the ltauthorgt element you might want to refer to the 7people7 de nitions much as you would use different packages in Perl or Java This is done by pre xing a tag with the namespace followed by a colon For example ltbook Xmlnspeop1e quothttpwwwfoobarcomnamesquotgt lttit1egt Lord of the Rings lttit1egt ltauthorgt ltpeop1e2namegt JRRTolkien ltpeop1enamegt ltpeop1etit1egt Sir ltpeop1etit1egt ltbookgt In order to use a namespace you have to declare it rst We did that above with the xmlns attribute inside the book tag lt declares the 7people7 namespace and points to the appropriate DTD The de nition doesn7t have to be at the root document you might nd it useful to introduce a separate namespace for a particular subsection of a document Following the standard XML scoping rules that namespace will remain usable within the element where it is declared If we only want one default namespace we can leave out the postcolon identi er the XML processor will then assume that everything is de ned within that namespace For example ltbook Xmlnsquothttpwwwfoobarcomnamesquotgt ltbookgt 5 Entities We saw a couple of entities de ned in the prolog For example we had ltENTITY jrrt quotJRR Tolkienquotgt lt ENTITY elvishkey quotelvish Xm1quotgt We can then use these within a later element adding an amp to the beginning and a semicolon to the end For example ltbookgt ltdescriptiongt the Author of The Lord of the Rings is ampjrrt he invented a grammar and semantics for Elvish which can be found at ampe1vishkey ltdescriptiongt The XML parser will replace entities with the objects they refer to There are also entities to represent those characters that XML wants to treat as special such as lt gt and amp They are amplt ampgt ampquot ampapos and ampamp respectively Also for nonASCII characters you can give the Unicode number corresponding to a character preceded by amp for example amp241 is an n with a tilde over it If you have large amounts of character data that you want to include for example you have HTML formatting instructions that you don7t want treated as XML you can use CDATA For example lt CDATA ltbgt this text will be bold lth2gt and this text 1argelth2gt ltbgt gt Note the two sets of brackets Everything inside the brackets will be ignored by the parser This is nice when you need to include code in an XML document Declared entities can also contain markup tags in addition to text For example you might want to do quot the rst string is a Uniform Resource Indicator URI this is meant to be a generalized naming scheme akin to peoplels SSNs The idea is that the URI provides a layer of abstraction even if an object moves it will keep the same URI The format is 0wner ID Description Language The or indicates whether the document is formally registered with a naming service like ISO An XML processor needs to know how to look this information up in a catalog that maps URIs to locations Now this is more exible because the URI doesnlt specify a hostname just a key to look up the DTD However this means that whatever is processing this XML needs to know how to do this In practice this is often not implemented and so browsers will default to using the URL 6 Linking to other documents As with HTML you can embed links to other documents within XMLi However XML links are much more expressive than HTML links For example image xmlns xlinkquothttp www w3 org1999x1inkquot x1inktypequotsimp1equot x1inkhrefquot1ogo gifquot x1inkshowquotembedquot gt This speci es that a welll use the xlink namespace b this is a 7simple7 link there7s also complex links but welll avoid these c a URL for nding the image and d how it should be displayed 7embed7 says fetch it immediately and place it in the page we could also do ltdoc1ink xmlns xlinkquothttp www w3 org1999x1inkquot xlink typequot51mp1equot x1inkhrefquothttp www cs usfcaeduquot x1inkshowquotrep1acequot xlinkactuatequotonRequestquot gtc1ick hereltdoc1inkgt to get to the USF CS homepage In this case x1inkshow was set to 7replace7 indicating that this document should replace the preVious one and x1inkactuate was set to 7onrequest which says that the link should be followed on the users requesti Notice that this is still a highlevel description this doesn7t say anything about how a browser for example should implement this 7 Display there are several ways in which you can specify how an XML document should be rendered The simplest which also works with HTML are Cascading Style Sheets CSS these specify how a tag should be rendered for example that ltbgt should use a particular font size and type A more interesting and powerful way to do this is to specify a transformation This is an XML document that describes how to turn an input XML document into an output XML document with different tags such as HTML To do transforms we need to rst talk a bit about Document Models and Schema 8 Document Models and DTDS A document model lets you specify the rules for your own particular avor of XML things like do books have to have an author element What are valid values for 7genre7 Can books have more than one title This feature is what makes XML so powerful rather than having a preset generalpurpose set of tags and elements that you have to scrunch into a shape that ts your needs HTML anyone you can design your own language that ts your problem The document model is also essential for programs that have to parse and manipulate XML Once a parser has the document model it becomes much easier both to parse the document and to check for errors Also it tells an agent how to generate XML so that other programs can read it 81 DTDs OK we7ve been talking about DTDs saying well get to it eventually so what are these things A DTD de nes the set of allowable elements the vocabulary the ways in which elements can be nested the grammar and the values attributes can take on more vocabulary and their default values 8 1 1 Entity declarations We talked about entities before remember they7re like macros You can also include them in a DTD 8 1 2 Element Declarations An element declaration looks like this ltELEMENT book author I volumes I isbn I title I price gt This says that there7s an element called book and that it can contain 0 or more author volumes isbn title and price subelements This third eld is called the content model I know all this jargon is really irritating Notice that the content model uses the standard regular expression syntax this means that you can specify that an element contains one or more 0 or 1 7 and use AND and OR to specify combinations So we might say ltELEMENT book author subtitle title price isbn volumes description gt This says that a book must have at least one author exactly one title at least one price an optional 0 or 1 subtitle exactly one isbn 0 or more volumes and zero or more descriptions lt ELEMENT author ALLgt says that author can contain any combination of subelements lt ELEMENT coauthor EMPTYgt says that an element must be empty lt ELEMENT title PCDATAgt says that a title can only contain character strings no subelements 813 Attribute Declarations Once you re done describing how elements t together you re ready to say What attributes and values go With each element The general syntax is ltATTLIST elementname namel type2 descripl name2 type2 descrip2 The description part speci es Whether an attribute is required and What the default values are for example ATTLIST book genre fantasy I scifi I mystery I horror fantasy id ID REQUIRED Genre can take one of four values fantasy is the default id is speci ed to be of type ID and is required this ensures that every book is given a unique identi er Data types are CDATA character data NMTOKEN a string Wo Whites pace ID IDREF reference to an ID ENTITY refers to a de ned ENTITY see above or a list of keywords There are others too take a look at the XML spec for all the types REQUIRED says that the programmer must sat a value IMPLIED says that the attribute is optional and that there is no default value For example ATTLIST book othermedia cd I pdf I audiotape IMPLIED We could use this to indicate that the book existed on nonprint media 814 An Example So here7s a possible DTD for our book document lt BTW here s how to add a comment This is our book DTD gt ltELEMENT book author subtitle title price publisher isbn volumes I descriptiongt ltELEMENT author PCDATAgt ltELEMENT title PCDATAgt ltELEMENT volumes volumegt ltELEMENT volume PCDATAgt ltELEMENT publisher PCDATAgt ltELEMENT isbn PCDATAgt ltATTLIST book genre fantasy I scifi I mystery I horror fantasy id ID REQUIRED 815 XML Schema For several reasons some folks donlt like DTDsi The syntax is odd and not like regular XMLi It can be hard to specify complex patterns and they can be unwieldy as they get larger So XML Schema have been proposed as a way of dealing with these problems XML Schema provide a way for you to describe your data using XML directly XML Schema are a relatively new thing and the standard is still evolving llm not going to go into more detail on Schema because of that Plus welve got to get to 9 Transforming XML One of the coolest things about XML and its regular structure is the fact that you can transform it from one representation to another automatically To do this you create a simple XMLbased of course document in a language called XSLT Extensible Style Language Transformations This means that if you get your data all nicely packaged into one XML format and then FooBaricom comes out with the new hot XML format next week you donlt have to start over or write a bunch of handrolled programs to get your data in the right formati Instead you just need to make an X document then pass the two to a transformation engine You can also use XSLT with servers that dynamically generate XML to get the data back in a form thatls useful for your needs In other words a server can just plan to send everyone back XMLi A client who wants the data in another format can just pass the server an XSLT le and the server will transform the data for the client No need to write your own parser or have a big heavyweight plugin on the client side reformatting your data If you change the way your data should be presented just change the XSLT le In order to understand XSL transforms we rst need to remember that when XML is parsed we get a tree This tree has elements as nodes and text at the leavesi Attributes are also considered to be at the leaves As a reminder let s look at a simple tree for this XML document ltxml version 10 gt ltbook genre scifi gt ltauthorgt William Gibson ltauthorgt lttitlegt Neuromancer lttitlegt ltpricegt 995 ltpricegt ltbookgt Igt genre scifi I I author gt William Gibson root book I I Title gt Neuromancer I IPrice gt 995 One interesting Wrinkle above the 7book7 node is an abstract node referred to as the root under It encompasses everything about the document including comments made outside of the scope of the book element The trick to XSL transforms is to Write a rule for each of the different levels in the tree plus a default rule for levels that don7t need special attention These rules Will have three components First a matching element that Will specify Which nodes should have this rule applied to themi Second a set of operators to apply to generate a result Third instructions on how to deal With the children of a node Not surprisingly the rules Will be expressed as an XML document It Will start out Wit ltXml versionquot10quotgt ltxsl stylesheet xmlns xslquothttp wwww3 org1999XSLTransformquot versionquot10quotgt The rst line should look familiar by nowi The second line is an element that speci es the namespace for the XSL transform language this is usually a good URL to user The transform Will happen Within the scope of this element Now for a matching ruler Let7s start With 7author ltxsl template matchquotauthorquotgt ltigt ltxslapplytemplates gt ltigt ltxsltemplategt This will italicize the author and apply any templates to the children of the author nodei Notice that all we re doing here is asking the transformer to insert some HTML at this point We can also write a rule to match the root document This will be useful for setting up the beginning of the document and nishing things off at the end ltxsltemp1ate match gt lthtm1gt ltbodygt ltxslapp1ytemplates gt ltbodygt lthtmlgt ltxsltemp1ategt This will begin by processing the root node printing out the HTML setup and then process the children of root thatls what ltxslapp1ytemplates gt does A complete stylesheet would also have similar rules for title book genre and price This works ne but so far it s only useful for very simple documents Luckily XSLT is much more power First off you can match on a wide variety of different features of a node in cluding attribute type parent child multiple elements and many more Here s a few examp es ltxsltemp1ate matchquottit1e I authorquotgt ltxslapp1ytemp1atesgt ltbgt ltxsltemp1ategt matches title or author ltxsltemp1ate matchquotvolumesvolumequotgt lth3gt ltxslapp1ytemp1atesgt h3gt ltxsltemp1ategt This matches a volume node whose parent is a volumes nodei ltxsltemp1ate matchquottit1equotgt lth2gt ltxslapp1ytemp1atesgt h2gt ltxsltemp1ategt this will match a title node that is one level away from the root node ie it is the child of a book node which is the child only of the root node 12 ltxs1template matchquottext Oquot gt ltfontgt ltxs1app1ytemp1atesgt ltfontgt ltxs1temp1ategt This will match the text nodes at the leaves ltxs1template matchquotbook genre fantasy gt This is a fantasy book ltpgt ltcentergt ltxs1app1ytemp1atesgt ltcentergt ltxs1temp1ategt This matches book elements whose genre attribute is fantasyi There are many other matching rules the resources on the class website list themi l more than one rule can apply to a node7 the most speci c is used This means that hierarchical rules outweigh rules that match a node7 direct matches outweigh wilclcarcls7 and rules that match both element and attribute outweigh element matches 91 Control structures You can also embed control structures within a match Rather than writing a complex expression7 you can write the equivalent of if and switch For examp e7 ltxs1template matchquotquotgt ltxs12if testquotse1f id amp1t 4 quotgt ID is less than 4 ltxs1app1ytemp1atesgt ltxs1 ifgt ltxs1temp1ategt Self refers to the node being processed Here we7re testing to see if the ID of the node is less than 4 ltxs1template matchquotquotgt ltxs1choosegt ltxs1 when testquotse1f titlequotgt Title node ltxs1whengt ltxs1 when testquotse1f authorquotgt Author node ltxs1whengt ltxs1otherwisegt Some other node ltxs1 otherwisegt ltxs1 choosegt ltxs1temp1ategt And here we have a 7switch7 statement Like switch or case in most lan guages once one condition matches the template 7shortcircuits7 to the end Only one match is m e So far we7ve just used ltxs1app1ytemp1ates gt to process subnodes and allowed the XSLT processor to pass text through unchanged This works great when our content is text and we just want to change the wrappers around it but sometimes you need to refer to or manipulate the value at the current node The XSL construct for retrieving the value of a node is ltxs1va1ueof select gt This says to select the value of the currently processed nodei Since there7s a path in the value of the select atribute we could also fetch for example the parent value or the root value One thing we might want to do is count the number of elements of a given type XSL provides a count function that lets us do that For example ltxs1temp1ate matchquotvolumesquotgt There are ltxs1va1ueof selectquotcount volumequot gt volumes in this book ltxs1temp1ategt or we could compute a discount price on the y ltxs1temp1ate matchquotpricequotgt The discount price is ltxs1va1ueof selectquot 10quot gt What a deal ltxs1temp1ategt This will subtract 1 from the value of price At times you will want to use iteration within a template For example maybe after we print the title of the book we want to generate a numbered list of the volumes To do that we can use ltxs1foreachgt like so ltxs1temp1ate match book gt ltxs1foreach select volumesvolume gt ltxs1va1ueof select positionO gt ltxs12text gt ltbrgt ltxs1foreachgt ltxs1temp1ategt Therels several new things in here The rst is xs12foreach which says that when the translator matches a book element it should apply the following transformation to each subnode of type volumesvolume The second new thing is the use of the position function This is asically a counter that gives an index to each matched node in the volumesvolume list The third new thing is the ltxs1textgt tag note that it s empty which instructs the matched node to spit out its contents as text You can also de ne temporary variables with in an XSL le This is useful for example if you want to keep a running total or for any of the many other things that variables are nice for Here are a few examples ltxslvariable name x gt lt defines a variable x gt ltxslvariable name destination select acapulco gt lt defines a variable destination set to the value acapulco gt ltxsl variable name condvariable gt ltxslchoosegt ltxsl when test x ampgt 7 gt ltxsltextgt999ltxsltextgt ltxslwhengt ltxslotherwisegt ltxsltextgt1199ltxsltextgt ltxslotherwisegt ltxslchoosegt ltxslvariablegt lt this is equivalent to the statement if x gt 7 condvariable 999 else condvariable 1199 gt Note also that you can refer to previously created variables by putting a 77 in front of themi As you might expect by this point the scope of a variable is con ned to the element in which it is de ne 10 Conclusions This document is designed to be a primer or an introduction to the ideas behind XML and XSLTi XSLT in particular is much more complex this has just hit some of the high notes This is what I want you to get for this class enough to know how to create and process fairly simple XML documents If you want to go deeper and I recommend it it s really interesting stuff there s lots of great resources available Here are a few 0 OlReillyls books In particular lld recommend Java and XML Learn ing XML and XSLTW All their books are great they make a real effort to tone down the jargon and present things in a straightforward manner with lots of examples 0 httpwwwizvoniorgxxlXSLTreferenceOutputindexihtml An XSLT reference 0 httpwwwivamlicomxsltutorialsintrodefaultiasp An XML tuto rial kind of MSVisualBasic oriented but good info httphotwiredilycosicomwebmonkey lots of web design articles in cludes howtos for XML and XSLTi 15 Software Agents and Electronic Commerce CS48626 Thematic Recap Chris Brooks Department of Computer Science University of San Francisco 260 Overview 0 In this class we ve discussed a number of thematically related topics including 0 Information and its peculiar properties Stages of an ecommerce transaction Agents and learning in an ecommerce setting Encryption Tools for discovery SOAP XML WSDL etc 261 Ecommerce transactions 0 The standard ecommerce transaction consists of three parts 0 Discovery finding what you want Negotiation settling on the terms 0 Exchange exchanging goods for payment 262 Information 0 The central role of information is one of the primary features separating electronic commerce from brickandmortar commerce 0 Buying and selling of digital information introduces a whole new set of problems and issues including 0 Finding it 0 Pricing it Protecting it 0 Distributing it 263 Information 0 Information can include 0 Information about what goods are available 0 Information about what sellersbuyers are around 0 Information about pricing and terms 0 Information about trustworthiness Goods themselves 264 Discovery Finding Informa tion 0 Discovery is the problem of finding 0 Who is selling what you want 0 Who is buying what you have 0 What sorts of goods are available 0 How goods are related 0 Most generally it means finding out about your possible options and acquiring the information needed to make a smart decision 265 Discovery on the Web 0 The most common method for finding information on the W is via a search engine 0 The typical search engine consists of three components 0 Crawling Storing and Indexing 0 Retrieval 0 Goal Give users the information that best meets their needs 266 Web Services Automating In formation Retrieval One of the most difficult issues in introducing agents into complex environments is language 0 How can a program determine the characteristics of a product 0 How can sellers describe complex rich data in a way that s easily accessible 0 Web Services provide a comprehensive interface for doing this 267 Web Services Automating In formation Retrieval XML provides an extensible language for describing and laying out data 0 XML is easily parsed into a tree 0 XML can then be transformed using XSLT into other XML representations or other languages such as HTML 0 DTDs and Schema allow a programmer to specify legal data structures 0 XML can be transmitted over HTTP 268 Web Services Automating In formation Retrieval SOAP provides a programmatic interface for exchanging XML 0 Provides the equivalent of remote procedure calls 0 WSDL allows a server to specify terms of protocol 0 All over port 80 no firewall issues 269 Recommenaer oysrems TIHCI ing what you want 0 One hard challenge with rich goods is finding out what it is you want 0 Space is highdimensional Consumers want to reduce their risk 0 Sellers want to suggest things that people would like 0 Recommender Systems can do this 0 Users who liked X like 0 If you like X you ll like 0 You bought XY and Z which are like 2610 Encryption Protecting Infor mation 0 A serious concern with transmitting information is protecting it 0 Encryption allows you to do this 0 Privacy preventing identity theft 0 Access control Authentication Verification 2611 Encryption Protecting Infor mation 0 Encryption is a big topic including Symmetric secretkey encryption 0 Asymmetric publickey encryption 0 Watermarking Public Key Infrastructure Zeroknowledge Protocols Digital Signatures and more 0 Each of these has their own particular application 2612 Copyright Protecting Infor mation 0 There are also legal mechanisms for protecting information 0 Copyright 0 Patent 0 Trademark 0 Developers can also choose how to exercise these rights using licenses such as 0 Commercial licenses Copyleft 0 Public Domain 0 Open Source 2613 Information Goods 0 Information can also be a commodity in its own right 0 Information has several interesting properties such as 0 Low marginal cost Nonexcludability Nonrivalry Experience good Ease of bundling 2614 Information Goods 0 Information goods can be priced according to a wide variety of schemes including Perarticle Pure Bundling Twopart Tariff Mixed bundling Block pricing 0 Nonlinear pricing 0 Goal Balance profits after learning against complexity 2615 Negotiation 0 Negotiation can be as simple as setting a price or as complex as designing a contract 0 Automated mechanisms for negotiation include game theory and auction theory 0 Goal construct welldefined and understood procedures that allow software agents to determine how to pricebid 2616 Game Theory 0 Game theory is designed to explain multiagent interactions in a selfinterested setting 0 Key idea How should an agent act given that every other agent is selfinterested 0 Key solution concept Nash equilibrium 0 Each agent is doing the best it can given what every other agent is doing 2617 Auction Theory 0 Auctions are a useful way to allocate goods in a decentralized way Easily automated Wellunderstood 0 Many types of auctions English Dutch Vickrey CDA 0 ln Vickrey truthtelling is the dominant strategy 0 Combinatorial auctions present a host of unsolved problems 0 Complexity Complementarity 2618 Payment 0 Payment has turned out to be one of the most challenging problems in electronic commerce 0 Many intelligentlooking schemes have failed 0 Too complicated No critical mass of users 0 Too many transactions 0 Credit Cards are still the dominant payment scheme Software Agents and Electronic Commerce CS48625 Intellectual Property 2 Chris Brooks Department of Computer Science University of San Francisco UISII39IDLIIII39IQ Ulgltal ll39llielleCIual Property 0 Once you ve made an intellectual property such as a program you need to decide what to do with it 0 You need to decide the terms under which people can use your software 251 Licensing 0 A license specifies the terms under which a piece of software can be used It can grant all of the terms that copyright does or just a subset It may specify 0 rules about copying 0 use for profit number of installations ownership do you own the software orjust use it Responsibility for usage technical support 252 Commercial Licenses 0 These are the traditional licenses that come with most shrinkwrapped software 0 Legal contract as copyright holder the authors can choose whatever usage terms they like 0 They typically prohibit users from tampering with modifying or redistributing the software 0 Often ownership remains with the vendor users are techinally leasing the code 0 Typically limits liability vendor is not responsible for damage 0 May also restrict usage duration number of machines reverse engineering 253 Public Domain 0 The simplest way to freely distribute your program is to put it into the public domain 0 No copyright is retained users can do whatever they want with your program 0 This includes selling it or converting it into a proprietary product and copyrighting the derivative work 254 Copyleft 0 Copyleft is more restrictive than putting something in the public domain 0 Copyleft is an idea promoted by the GNU foundation 0 Copyleft requires that anyone who redistributes software either original or changed must release this software under copyleft 0 Note that you can charge for this new software but you can t change the licensing terms 0 This provides developers with an incentive to delevlop free software 255 Copyleft 0 Stallman If you will make your software free you can use this code 0 Example The C frontend to gcc was developed in industry GNU s copyleft required it to be copylefted since it used copylefted code 256 Examples of Copylefted Soft ware 0 Emacs 0 gcc 0 Many unix tools 0 Anything released under the GNU Public license 257 GNU Public License 0 The GNU Public license is the most wellknown implementation of the Free Software principles 0 Distribution terms everyone has the right to use modify and redistribute copylefted code as long as the rights to this code or any derived code are not changed 0 In other words you can t weaken the use conditions or strengthen restrictions on copylefted code 253 Free Software 5 0 It s useful to think a bit about what free software really means 0 Free as in speech not as in beer 0 In other words you have the right to do what you want with it not that you re obligated to get it without paying 259 Free Software 0 GNU software freedoms The freedom to run the program for any purpose 0 The freedom to study the program and how it works ie source code access 0 The freedom to redistribute copies The freedom to modify the program and redistribute the modified version 2510 The Free Software Foundation 0 Started by Richard Stallman in 1985 as a response to the ovenNhelmingly proprietary nature of software at the time 0 No free OSes Unix was very expensive few free tools 0 Goal develop a free 08 along with a set of tools for that 08 editor compiler mail reader etc 0 This system was referred to as GNU Gnu s not Unix 0 When the linux kernel was developed in the early 1990s GNU finally had a free 08 to run on 2511 Lesser GPL 0 GNUFSF also offers something called the Lesser GPL 0 Allows GPL ed libraries to be linked into nonfree code which can then be proprietary 0 Goal encourage adoption of a particular standard 0 Or the free library may do the same job as a widelyexisting nonfree library 0 For example the GNU C library 2512 Open Source 0 Open Source is a broader term that covers a number of different possible licensing agreements 0 Basic criteria 0 License must not prevent redistribution and must allow free distribution 0 Source code for the program must be publically available Derived works must be covered under the original license 0 License may require modifications to be distributed a separate patches or be clearly named or identified 2512 Open Source 0 License may not discriminate against groups of users 0 For example countries may have export restrictions An open source license may remind users to obey the law but cannot explicitly incorporate these restrictions 0 Also cannot restrict use to for example only noncommercial entities 0 Cannot require that it be distributed only with other opensource works 2514 Examples of Open Source software Mozilla Apache Perl Python all GNU tools 0 PHP openSSH Much more 2515 Economics of Open Source 0 A common objection to open source is But I need to eat 0 If your program is freely available how can you make money from it 0 Maintenancedevelopment Most programmers spend a large fraction of their time maintaining tools or modifying them for a particular business this won t change if the underlying codebase is open source 2516 Economics of Open Source 0 Supportconsultation Just because something is free doesn t mean there s no value for people who are experts at using it 0 Paid development If a tool is widely accepted or deemed valuable industry will subsidize its development even if the end product is open source because it s valuable to them eg Apache g perl ANTLR 2517 Open Source as a Business Model 0 Some managers may also be reluctant to adopt an opensource model 0 Why should we give away something that cost us lots of to develop 0 Reliability open source is arguably more reliable as more people are using and testing the code 0 Technical superiority this is an open argument but 08 proponents argue that having more developers leads to a better product 0 Rapid response Faster turnaround times allow businesses to respond to customer needs more easily 2513 Open Source as a Business Model 0 Market penetration 08 may allow a firm to add developments that would not be feasible otherwise For example ports to less popular operating systems 0 Remember software has a network effect getting a large user base makes it more valuable 2519 Open Source as a Business Model 0 Potential Opensource business models 0 Support sellers RedHat Give away the product sell support aftersale service 0 Lossleader Netscape Java You give away your software to help sales of related closed software 2520 Open Source as a Business Model 0 Product improvement SGI A hardware company supports and ships opensource software such as Samba that improves their other products 0 Accessorizing O Reilly VA research Selling systems or manuals that use or describe opensource systems 39 It s not too different a consideration from the discussion on how to sell information goods when copying is prevalent 2521 Creative Commons 0 These are just a few of the potential ways in which you may want to control the use of your IP 0 Creative Commons is an organization started by IP and CS experts devoted to increasing people s ability to control access to their work 0 Provides a broad set of potential licenses for creators of IP 0 Goals Increase amount and accessibility of online source material 0 Also provides a standard metadata encoding for these licenses using HTML and RDF 0 This makes the licenses standardized and machinereadable 2522 Creative Commons 0 Some CC licenses 0 Attribution Anyone can use your work but they must give you credit 0 Noncommercial People can use and display your work for noncommercial purposes 0 No derivative works People can use or copy your work but not modify it 0 Share alike People can distribute derivative works as long as original licensing terms remain 0 Full copyright You retain all rights to how your work is used