O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Subsequences with Parentheses

In fact, you can get even more powerful using the +, *, and ? operators inside sequences because, using parentheses, you can create subsequences—that is, sequences inside sequences.

For example, say that I wanted the <CUSTOMER> element to be capable of holding one or more <NAME> element. For each <NAME> element, I also want to allow a possible <CREDIT_RATING> element. I can do that like this, where I'm creating the subsequence (NAME,CREDIT_RATING?) and allowing that subsequence to appear one or more times in the <CUSTOMER> element:

Listing . ch03_03.xml
 
<?xml version = "1.0" standalone="yes"?>
<!DOCTYPE DOCUMENT [
<!ELEMENT DOCUMENT (CUSTOMER)*>
<!ELEMENT CUSTOMER ((NAME,CREDIT_RATING?)+,DATE*,ORDERS)> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required