[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: convert xml with schema to html with xslt
It looks like, that your XML document is in a namespace (defined by, xmlns="urn:Verlag"). But your stylesheet doesn't consider namespaces. for example, this template: <xsl:template name="paragraph" match="para"> will not match the "para" node from XML, as "para" node in your XML is in a namespace (which is, "urn:Verlag"). Importing the schema in the stylesheet won't solve this problem, because schema import in XSLT 2.0 is for a different need (basically to provide the schema types and declarations to the stylesheet). I think, something like below may solve this problem: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="urn:Verlag" version="2.0"> <xsl:template name="paragraph" match="ns1:para"> ... </xsl:stylesheet> On Mon, Dec 21, 2009 at 3:51 PM, Lajos Joo <lajosjoo@xxxxxxxxx> wrote: > Hello! > > I have a problem. I have a small xml file which has a schema declaration in the root element. I cannot convert it to html with an xslt file. If i remove the schema declaration the conversion is fine. > Please suggest me how to correct this. > I have included a shcema import but it didnt help: > <xsl:import-schema namespace="urn:Verlag" schema-location="urn:Verlag http://192.168.190.181:8879/xml/STRUKTUR.xsd" /> > > The xml file looks like this: > <LOSCHNIGG xmlns="urn:Verlag" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:Verlag http://192.168.190.181:8879/xml/STRUKTUR.xsd"> > B B B B <metadaten> > B B B B B B B B <gilt-ab>1000-01-01</gilt-ab> > B B B B B B B B <gilt-bis>9999-12-31</gilt-bis> > B B B B B B B B <Fassung_Publikation> > B B B B B B B B B B B B <Publikationsstand>2009-12-19</Publikationsstand> > B B B B B B B B B B B B <Release_Version>1</Release_Version> > B B B B B B B B </Fassung_Publikation> > B B B B </metadaten> > B B B B <para> > text... > B B B B </para> > </LOSCHNIGG> > > The xml works fine and the xsd is in the right place. > > The xsl looks like this: > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="2.0"> > > <!-- B B <xsl:import-schema namespace="urn:Verlag" schema-location="urn:Verlag http://192.168.190.181:8879/xml/STRUKTUR.xsd" />--> > > B B B B <xsl:output encoding="UTF-8" indent="yes" method="html" version="1.0" /> > > B B B B <xsl:template match="@*|node()"> > B B B B B <xsl:copy> > B B B B B B B <xsl:apply-templates select="@*|node()"/> > B B B B B </xsl:copy> > B B B B </xsl:template> > > B B B B B B B B <xsl:template name="paragraph" match="para"> > B B B B B B B B B B B B <xsl:element name="p"> > B B B B B B B B B B B B B B B B <xsl:apply-templates/> > B B B B B B B B B B B B </xsl:element> > B B B B B B B B </xsl:template> > > B B B B <xsl:template match="/"> > B B B B B B B B <xsl:element name="html"> > B B B B B B B B B B B B <xsl:element name="head"> > B B B B B B B B B B B B B B B B <xsl:element name="title">Preview</xsl:element> > B B B B B B B B B B B B </xsl:element> > B B B B B B B B B B B B <xsl:apply-templates/> > B B B B B B B B </xsl:element> > B B B B </xsl:template> > </xsl:stylesheet> > > Thank you! > Lajos -- Regards, Mukul Gandhi
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|