[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Namespace problem, part two
Thanks to the help I received yesterday, the pre-load stylesheet I am running to ready our XML documents for FrameMaker is running correctly. Last night it appeared that the complementary stylesheet which ran post-save was also functioning correctly, but apparently not. The post-save stylesheet breaks the output document apart; the initial output document is correct but lower-order output documents are missing a namespace node. Here is a trivial XML file which might be passed to the post-save stylesheet (test.xml): ---- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE document SYSTEM "../../xml_utils/fmdocs.dtd"> <document> <title>Software Development</title> <included srcfile="qa.xml"> <document index="Y"> <title id="Head">Q.A. Cycle</title> <steps> <step>Test application</step> <step>Isolate problem</step> <step>Submit bug report</step> <step>Wait a while</step> <step>When anything happens, go back to step 1</step> </steps> </document> </included> </document> ---- Here is a cut-down post-save stylesheet (save.xml): ---- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xalan="http://xml.apache.org/xalan" extension-element-prefixes="xalan"> <xsl:output method="xml" encoding="UTF-8" /> <!-- NOTE this stylesheet is run inside Framemaker (i.e. by Xalan) and thus is confined to XSL 1.0 and any Xalan extensions --> <!-- main document and subdocuments --> <xsl:template match="/* | included/document | included/section | included/content" priority="2"> <!-- insert stylesheet PI --> <xsl:processing-instruction name="xml-stylesheet"> <xsl:text>href="../../xml_utils/hcdoc2html.xsl" type="text/xsl"</xsl:text> </xsl:processing-instruction> <xsl:variable name="ln" select="local-name()" /> <xsl:element name="{$ln}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:attribute name="xsi:noNamespaceSchemaLocation">../../xml_utils/hcdocs.xsd</xsl:attribu te> <xsl:apply-templates select="@*" /> <xsl:apply-templates /> </xsl:element> </xsl:template> <xsl:template match="included" priority="2"> <xsl:variable name="file" select="@srcfile" /> <!--include srcfile="{$file}" /--> <xsl:element name="include"> <xsl:attribute name="srcfile"><xsl:value-of select="$file" /></xsl:attribute> </xsl:element> <!-- separate XML file for the included content --> <xalan:write select="$file"> <xsl:apply-templates /> </xalan:write> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates /> </xsl:copy> </xsl:template> <xsl:template match="@*"> <xsl:copy-of select="." /> </xsl:template> </xsl:stylesheet> ---- Expected output is two files: (test.xml): ---- <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="../../xml_utils/hcdoc2html.xsl" type="text/xsl"?> <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xml_utils/hcdocs.xsd"> <title>Software Development</title> <include srcfile="qa.xml"/> </document> ---- (qa.xml as wanted): ---- <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="../../xml_utils/hcdoc2html.xsl" type="text/xsl"?> <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xml_utils/hcdocs.xsd" index="Y"> <title id="Head">Q.A. Cycle</title> <steps> <step>Test application</step> <step>Isolate problem</step> <step>Submit bug report</step> <step>Wait a while</step> <step>When anything happens, go back to step 1</step> </steps> </document> ---- When the save stylesheet is run, the first (outer) document is created correctly, but the second (inner) document (qa.xml) lacks the xmlns:xsi (namespace) node: (qa.xml as created): ---- <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="../../xml_utils/hcdoc2html.xsl" type="text/xsl"?> <document xsi:noNamespaceSchemaLocation="../../xml_utils/hcdocs.xsd" index="Y"> <title id="Head">Q.A. Cycle</title> <steps> <step>Test application</step> <step>Isolate problem</step> <step>Submit bug report</step> <step>Wait a while</step> <step>When anything happens, go back to step 1</step> </steps> </document> ---- I know a lot more about namespace nodes and attribute nodes than I did yesterday, but obviously I still don't know enough. Can some kind soul explain what I am missing here? Thanks in advance Trevor
|
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
|