[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

DTD Namespaces and xslt output problems

Subject: DTD Namespaces and xslt output problems
From: "JSRawat" <jrawat@xxxxxxxxxxxxxx>
Date: Thu, 14 Jul 2011 12:29:40 +0530
 DTD Namespaces and xslt output problems
Hi All,
I have copied a sample DTD. I am not able to convert following INPUT using
following XSLT. If I comment DocType and Namespaces Attributes of
<component> in the input file, then I am getting the required output. I want
to know the reason behind this and what should I do in the xslt so that I
will get the required result. Thanks in advance.

SAMPLE DTD
<!ELEMENT component (header,body)>
<!ATTLIST component
    xmlns:wiley CDATA #FIXED "http://www.wiley.com/namespaces/wiley/wiley"
	xmlns:cms CDATA #FIXED "http://cms.wiley.com"
	xmlns:dctm CDATA #FIXED "http://www.documentum.com"
	dctm:obj_id CDATA #IMPLIED
	dctm:obj_status CDATA #IMPLIED
	dctm:version_label CDATA #IMPLIED
	dctm:link_version_label CDATA #IMPLIED
	cms:chunk (yes|no) #IMPLIED
	cms:link CDATA #IMPLIED
	xml:id ID #IMPLIED
	version (1.0.3) #REQUIRED
	xmlns CDATA #FIXED "http://www.wiley.com/namespaces/wiley">

<!ELEMENT header (publicationMeta,contentMeta)>
<!ATTLIST header
	xmlns:cms CDATA #FIXED "http://cms.wiley.com"
	xmlns:dctm CDATA #FIXED "http://www.documentum.com"
	dctm:obj_id CDATA #IMPLIED
	dctm:obj_status CDATA #IMPLIED
	dctm:version_label CDATA #IMPLIED
	dctm:link_version_label CDATA #IMPLIED
	xmlns CDATA #FIXED "http://www.wiley.com/namespaces/wiley">

<!ELEMENT body (section)>
<!ATTLIST body
	xmlns:cms CDATA #FIXED "http://cms.wiley.com"
	xmlns:dctm CDATA #FIXED "http://www.documentum.com"
	dctm:obj_id CDATA #IMPLIED
	dctm:obj_status CDATA #IMPLIED
	dctm:version_label CDATA #IMPLIED
	dctm:link_version_label CDATA #IMPLIED
	xmlns CDATA #FIXED "http://www.wiley.com/namespaces/wiley">

<!ELEMENT contentMeta (title)>
<!ATTLIST contentMeta
	xmlns:cms CDATA #FIXED "http://cms.wiley.com"
	xmlns:dctm CDATA #FIXED "http://www.documentum.com"
	dctm:obj_id CDATA #IMPLIED
	dctm:obj_status CDATA #IMPLIED
	dctm:version_label CDATA #IMPLIED
	dctm:link_version_label CDATA #IMPLIED
	xmlns CDATA #FIXED "http://www.wiley.com/namespaces/wiley">

<!ELEMENT publicationMeta (doi)>
<!ATTLIST publicationMeta
	xmlns:cms CDATA #FIXED "http://cms.wiley.com"
	xmlns:dctm CDATA #FIXED "http://www.documentum.com"
	role CDATA #IMPLIED
	dctm:obj_id CDATA #IMPLIED
	dctm:obj_status CDATA #IMPLIED
	dctm:version_label CDATA #IMPLIED
	dctm:link_version_label CDATA #IMPLIED
	cms:chunk (yes|no) #IMPLIED
	cms:link CDATA #IMPLIED
	position CDATA #IMPLIED
	accessType CDATA #IMPLIED
	xmlns CDATA #FIXED "http://www.wiley.com/namespaces/wiley">

<!ELEMENT section (p)>
<!ATTLIST section
	xmlns:cms CDATA #FIXED "http://cms.wiley.com"
	xmlns:dctm CDATA #FIXED "http://www.documentum.com"
	dctm:obj_id CDATA #IMPLIED
	dctm:obj_status CDATA #IMPLIED
	dctm:version_label CDATA #IMPLIED
	dctm:link_version_label CDATA #IMPLIED
	xmlns CDATA #FIXED "http://www.wiley.com/namespaces/wiley">

<!ELEMENT doi (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT p (#PCDATA)*>

INPUT
<?xml version="1.0"?>
<!DOCTYPE component SYSTEM "sample.dtd"> <component version="1.0.3"
xmlns:wiley="http://www.wiley.com/namespaces/wiley/wiley"
xmlns="http://www.wiley.com/namespaces/wiley" xml:id="MBO31"> <header>
  <publicationMeta>
    <doi>10.1111/1432-1033</doi>
  </publicationMeta>
  <contentMeta>
   <title>Title text</title>
  </contentMeta>
</header>
<body>
 <section>
  <p>Paragraph text</p>
 </section>
</body>
</component>

XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:wiley="http://www.wiley.com/namespaces/wiley/wiley" 
                xmlns:cms="http://cms.wiley.com" 
                xmlns:dctm="http://www.documentum.com"
                exclude-result-prefixes="xs wiley cms dctm"
                version='2.0'>

<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>

<xsl:template match="component">
 <html>
  <head><title><xsl:value-of
select="header/contentMeta/title"/></title></head>
  <body><xsl:apply-templates/></body>
 </html>
</xsl:template>

<xsl:template match="header">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="publicationMeta"/>

<xsl:template match="contentMeta">
 <div class="fm">
  <xsl:apply-templates/>
 </div>
</xsl:template>

<xsl:template match="body">
 <div class="bdy">
  <xsl:apply-templates/>
 </div>
</xsl:template>

<xsl:template match="p">
 <p>
  <xsl:apply-templates/>
 </p>
</xsl:template>

<xsl:template match="title">
 <h1>
  <xsl:apply-templates/>
 </h1>
</xsl:template>

</xsl:stylesheet>

CURRENT OUTPUT
<?xml version="1.0" encoding="UTF-8"?>10.1111/1432-1033Title textParagraph
text

REQUIRED OUTPUT
<?xml version="1.0" encoding="UTF-8"?>
<html>
   <head>
      <title>Title text</title>
   </head>
   <body>
      <div class="fm">
         <h1>Title text</h1>
      </div>
      <div class="bdy">
         <p>Paragraph text</p>
      </div>
   </body>
</html>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.