Subject: [xsl] DTD Namespaces and xslt output problems From: "JSRawat" <jrawat@xxxxxxxxxxxxxx> Date: Thu, 14 Jul 2011 12:29:40 +0530 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] format-dateTime and time , Michael Kay | Thread | Re: [xsl] DTD Namespaces and xslt o, Brandon Ibach |
[xsl] format-dateTime and time zone, Birnbaum, David J | Date | Re: [xsl] DTD Namespaces and xslt o, Brandon Ibach |
Month |