[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: capturing variables or not?
Hi Edward, > I know how to do the template match, and all that neat stuff with normal XML > (ie <tag></tag>). But now after being > away from DTDs, XML, and XSL for 2 1/2 months I have to write a style sheet > for an xml document, and I'm at a loss > on how to match these tags. (Please bear in mind I did not write the XML) > > The XML is written in the following way! > > <?xml version="1.0" standalone="yes"?> > <dppo:document> > <dppo:titleDef> > Fiji: Crisis Over...or is it? > </dppo:titleDef> > <dppo:packetDef> > <dppo:titleDef> > Summary > </dppo:titleDef> > <dppo:paraDef> > <dppo:textDef> > Hostages held in Parliament since 19 May 2000 were released xxx. > Ratu Josefa Iloilo will be sworn in as Fiji`s new president on > Tuesday, 18 July. > Fiji`s two-month political coup is over, but the hostage crisis is a > huge disaster for Fiji. > The fabric of multi-culturalism and harmonious race relations has > been severely strained. > The economy, which was beginning to show signs of recovery after > years of stagnation, is hobbled. > </dppo:textDef> > </dppo:paraDef> > </dppo:packetDef> > </dppo:document> > > (Note: These are over simplified stylesheets, without any of the bells and > whistles) I hope your simplification also dropped the namespace declaration. The namespace prefix "dppo" must be declared in your XML (preferably in the top-level element), e.g.: xmlns:dppo="some-URI" > I tired doing the following but XSLT looks at it as a variable > so it wants me to declare it as a variable. Don't know what you mean by "variable" ... > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0" > xmlns="http://www.w3.org/TR/REC-html40" > xmlns:fo="http://www.w3.org/1999/XSL/Format" > result-ns="fo"> > > <xsl:template match="/"> > <HTML> > <HEAD> > <TITLE> > </TITLE> > </HEAD> > <BODY> > <xsl:apply-templates /> > </BODY> > </HTML> > </xsl:template> > > <xsl:template match="dppo:document"> > <xsl:apply-templates /> > </xsl:template> The XSLT engine must complain about the none declared prefix "dppo". > </xsl:stylesheet> > > > When I do, the text does display however its not really being > matched by anything except the variable declaration! > So the text cannot really be manipulated by the stylesheet > just displayed. > > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0" > xmlns="http://www.w3.org/TR/REC-html40" > xmlns:fo="http://www.w3.org/1999/XSL/Format" > result-ns="fo" > xmlns:dppo="file:/dev/null"> Ok - here is such a declaration. But the used namespace "file:/dev/null" must be the same is in your XML source! In this case the template with match="dppo:document" will be applied. BTW: what is result-ns? I believe the xsl:stylesheet element doesn't have an attribute like this. > <xsl:template match="/"> > <HTML> > <HEAD> > <TITLE> > </TITLE> > </HEAD> > <BODY> > <xsl:apply-templates /> > </BODY> > </HTML> > </xsl:template> > > <xsl:template match="dppo:document"> > <xsl:apply-templates /> > </xsl:template> > </xsl:stylesheet> > > I thought of trying to capture the information as a variable would > but I'm not quite sure how to do that. I began to try the following > and was not sure if it would work. [rest snipped] Hope this helps, Oliver /-------------------------------------------------------------------\ | ob|do Dipl.Inf. Oliver Becker | | --+-- E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx | | op|qo WWW: http://www.informatik.hu-berlin.de/~obecker | \-------------------------------------------------------------------/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|