Click here to Skip to main content
15,893,923 members
Articles / Programming Languages / XML

XInclude

Rate me:
Please Sign up or sign in to vote.
2.80/5 (5 votes)
30 Oct 2001 76.6K   1.9K   14  
XML <xinclude> implementation using XML SAX2 API from Microsoft XML Parser
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?process-ins attr1="value1" attr2="value2"?>
<?another-pi attr3="value3" attr4="value4"?>
<!DOCTYPE sections SYSTEM "external.dtd" [
<!NOTATION GIF SYSTEM "gif">
<!ELEMENT sections EMPTY>
<!ATTLIST sections href CDATA #REQUIRED>
<!ENTITY nbsp "&#160;">
<!ENTITY parsedExtEntity SYSTEM "parsed.xml">
<!ENTITY unparsedExtEntity SYSTEM "picture.gif" NDATA GIF>
<!ENTITY % paramEntity "href CDATA #REQUIRED">
<!ENTITY % paramExtEntity SYSTEM "param.dtd">
]>
<sections xmlns:xinclude="http://www.w3.org/2001/XInclude">
  <section>
    <part1>
      <included>Part 1:1</included>
      <included>Part 1:2</included>
      <included>Part 1:3</included>
    </part1>
  </section>
  <section>
    <part2>
      <included>Part 2:1</included>
      <included>Part 2:2</included>
    </part2>
  </section>
  <!-- section>
    <xinclude:include href="part3a.xml"/>
    <xinclude:include href="part3b.xml"/>
  </section -->
  <section>
    <part4>
       <included>Part 4:1</included>
       <included>Part 4:2</included>
    <!--included>Part 4:3</included>
       <included>Part 4:4</included>
       <included>Part 4:5/included -->
    </part4>
  </section>
  <section>
    <part5 xmlns:xinclude="http://www.w3.org/2001/XInclude">
      <part5a>
        <included>Part 5a:1</included>
        <included>Part 5a:2</included>
        <included>Part 5a:3</included>
      </part5a>
      <part5b>
        <included>Part 5b:1</included>
        <included>Part 5b:2</included>
        <included>Part 5b:3</included>
      </part5b>
    </part5>
  </section>
  <![CDATA[Literal Text]]>
  <![CDATA[
  Literal Text
  ]]>
  <cdata>
    <![CDATA[Included Literal Text]]>
    <![CDATA[
    Included Literal Text
    ]]>
  </cdata>
  &lt;text&gt;
  &nbsp;
  &ext;
  <part>
    <subpart>
    </subpart>
  </part>
  This text will be included directly
  &lt;xml&gt;
    Escaped (&amp;) Output 
  &lt;/xml&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Title&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;p&gt;Body
    &lt;/body&gt;
  &lt;/html&gt;
  <section>
    <nestedpi>
      <included>Nested PI removed</included>
    </nestedpi>
  </section>
</sections>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions