Are Warlords and Beyond the Sword two separate expansions for Civilization IV or does the second build on the first?

Beyond the Sword includes all new gameplay elements added in Warlords, including Great Generals, vassal states, A.I. improvements, new Civilizations, etc. The only thing that Beyond the Sword is missing are the 8 game scenarios that came with Warlords.

So basically, unless you really want to play the specific scenarios that came with Warlords, you're safe going straight to Beyond the Sword.