Usage is straightforward:
java -jar trang.jar input.xml output.xsd
Tool page is here. Manual is here. Code is hosted on google code.
The tool can do much more. Especially conversion between different schema languages...
java -jar trang.jar input.xml output.xsd
require 'rubygems' require 'mechanize' a = WWW::Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } a.get('http://google.com/') do |page| search_result = page.form_with(:name => 'f') do |search| search.q = 'Hello world' end.submit search_result.links.each do |link| puts link.text end end
earch_result.links.each
) and manipulate (eg: search.q = 'Hello world'
) a web page.
def page = new XmlSlurper(new org.cyberneko.html.parsers.SAXParser()).parse('http://groovy.codehaus.org/') def data = page.depthFirst().grep{ it.name() == 'A' && it.@href.toString().endsWith('.html') }.'@href' data.each { println it }
import com.gargoylesoftware.htmlunit.WebClient def webClient = new WebClient() def page = webClient.getPage('http://www.google.com') // check page title assert 'Google' == page.titleText // fill in form and submit it def form = page.getFormByName('f') def field = form.getInputByName('q') field.setValueAttribute('Groovy') def button = form.getInputByName('btnG') def result = button.click() // check groovy home page appears in list (assumes it's on page 1) assert result.anchors.any{ a -> a.hrefAttribute == 'http://groovy.codehaus.org/' }
In corporate environments you are building products, that will never see the light of day in any meaningful way. They are only used by internal people for very narrow things. These are products that would never survive in the outside world. They are just that bad. They have bad features, they are not usable, they don't meet a real need, even to the business... yeah it's really sad ... if you love the stuff, if you are a thoughtful developer, you are in the wrong place!
In corporate environments the product don't have to be good. Sometimes they don't even have to exist ...
The corporate environments are awful!
Professional Pessimism
Oslo is a modeling tool that sits on top of a database that stores metadata and application data and blends it all together in one ball of wax ... wow, what I just described is Access!
Some DSLs will live and some DSLs will die...
Speed up your Data-Driven JSF/Seam Application by Two Orders of Magnitude is a very interesting article about improving performance in a web application.
It is a perfect example for the fact that powerful technologies layered on top of existing technologies are always Leaky Abstractions.
The cool thing however is, that all the problems could be solved by means that are provided by the used technologies. No hacks were necessary! I guess that speaks for Seam as a well designed framework…
We're still figuring this stuff out. All of us.
@Entity public class Parent { @Id @GeneratedValue private long id; @Version private int version; private String name; @OneToMany(cascade = CascadeType.ALL) @JoinColumn(name = "parent_id", nullable=false) @org.hibernate.annotations.IndexColumn(name = "parent_index") List<Child> children = new ArrayList<Child>(); ...
@Entity public class Child { @Id @GeneratedValue private Long id; @Version private int version; private String name; @ManyToOne @JoinColumn(name = "parent_id", updatable = false, insertable = false, nullable=false) private Parent parent; ...
Hibernate: insert into Parent (name, version, id) values (?, ?, ?) Hibernate: insert into Child (name, price, version, parent_id, parent_index, id) values (?, ?, ?, ?, ?, ?) Hibernate: update Child set parent_id=?, parent_index=? where id=?
@Entity public class Parent { @Id @GeneratedValue private long id; @Version private int version; private String name; @OneToMany(cascade = CascadeType.ALL) @JoinColumn(name = "parent_id", updatable = false, insertable = false, nullable=false) @org.hibernate.annotations.IndexColumn(name = "parent_index") List<Child> children = new ArrayList<Child>(); ...
@Entity public class Child { @Id @GeneratedValue private Long id; @Version private int version; private String name; @ManyToOne @JoinColumn(name = "parent_id", updatable = false, insertable = false, nullable=false) private Parent parent; ...
Hibernate: insert into Parent (name, version, id) values (?, ?, ?) Hibernate: insert into Child (name, price, version, parent_id, parent_index, id) values (?, ?, ?, ?, ?, ?)
EntityManagerFactory emf = Persistence.createEntityManagerFactory("test"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); tx.begin(); Parent newParent = new Parent(); newParent.setName("Parent1"); Child newChild = new Child(); newChild.setName("Child1"); newParent.getChildren().add(newChild); newChild.setParent(newParent); em.persist(newParent); em.flush(); tx.commit();