Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Nov 10, 2013
1 parent 19bf412 commit ffb10c3
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/site/markdown/example-xsd.md.vm
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,29 @@ interface. It works with your default DOM implementation.
For example:

```java
String xsd = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>",
+ "<xs:element name='payments'/>",
+ "</xs:schema>";
Collection<SAXParseException> errors = new XSDDocument(xsd).validate(
new StreamSource(
IOUtils.toInputStream(
"<orders><order id="4">Coffee to go</order></orders>",
"UTF-8"
)
)
);
if (errors.isEmpty()) {
System.out.println("XML is valid");
} else {
System.out.println("XSD validation failed: " + errors);
import com.jcabi.xml.XSDDocument;
import java.util.Collection;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.IOUtils;
import org.xml.sax.SAXParseException;
public class Main {
public void main(String[] args) {
String xsd = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>",
+ "<xs:element name='payments'/>",
+ "</xs:schema>";
Collection<SAXParseException> errors = new XSDDocument(xsd).validate(
new StreamSource(
IOUtils.toInputStream(
"<orders><order id="4">Coffee to go</order></orders>",
"UTF-8"
)
)
);
if (errors.isEmpty()) {
System.out.println("XML is valid");
} else {
System.out.println("XSD validation failed: " + errors);
}
}
}
```

0 comments on commit ffb10c3

Please sign in to comment.