[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] DTD Namespaces and xslt output problems
Subject: Re: [xsl] DTD Namespaces and xslt output problems From: Ganesh Babu N <nbabuganesh@xxxxxxxxx> Date: Fri, 15 Jul 2011 10:33:43 +0530 |
Dear JS, You include xpath-default-namespace in your XSL it will solve the problem. Regards, Ganesh On Thu, Jul 14, 2011 at 2:17 PM, JSRawat <jrawat@xxxxxxxxxxxxxx> wrote: > Thanks!!! > > -----Original Message----- > From: Brandon Ibach [mailto:brandon.ibach@xxxxxxxxxxxxxxxxxxx] > Sent: Thursday, July 14, 2011 12:49 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] DTD Namespaces and xslt output problems > > Your sample document, as well as any document conforming to the given > DTD, has a default namespace declared > (http://www.wiley.com/namespaces/wiley). However, the template match > patterns in your XSLT are attempting to match elements that are not in > any namespace. > > You either need to declare a prefix for the input document's default > namespace and use that in the match patterns or use the > "xpath-default-namespace" attribute, probably on the "xsl:stylesheet" > element, to declare the namespace for the unprefixed element names in > your match patterns. > > -Brandon :) > > > On Thu, Jul 14, 2011 at 2:59 AM, JSRawat <jrawat@xxxxxxxxxxxxxx> wrote: >> 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] DTD Namespaces and xslt o, JSRawat | Thread | Re: [xsl] DTD Namespaces and xslt o, Andrew Welch |
Re: [xsl] format-dateTime and time , Michael Kay | Date | [xsl] Need to find element name of , charlieo0 |
Month |