| | |
XML to XML via XSL Transform Error...
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 12
Reputation:
Solved Threads: 3
Here is a sample of the XML that I am starting with:
XML: any.xml
XSL: any.xsl
The XML Result: temp.xml
The issue I am having is when I validate the output XML, temp.xml it comes back with an error that happens right here (line 8 of temp.xml):
It references that the reason for the error is because it expects '!' or '?'.... And I am at a loss on how to "fix" it.
XML: any.xml
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="any.xsl"?> <root> <device> <device_Info> <name>Name 1</name> <type>Type</type> </device_Info> <drive_Pair> <status>Ready</status> <Local> <l_name>10E5</l_name> </Local> <Remote> <l_name>0651</l_name> </Remote> </drive_Pair> #Can be 1 or many <drive_Pair>'s {<drive_Pair> ... </drive_Pair>} # Can only be 1 Totals <Totals> <Local> <l1_invalid_mbs>0.0</l1_invalid_mbs> <l2_invalid_mbs>0.0</l2_invalid_mbs> </Local> </Totals> </device> #Can be 1 or many <device>'s {<device> ... </device>} </root>
XSL: any.xsl
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" standalone="yes" cdata-section-elements="devices" indent="yes"/> <xsl:template match="/root/device"> <xsl:element name="devices"> <xsl:for-each select="device_Info"> <device name="{name}" type="{type}"/> </xsl:for-each> <xsl:for-each select="drive_Pair"> <drive_Pair status="{status}" local="{Local/l_name}" remote="{Remote/l_name}"/> </xsl:for-each> <xsl:for-each select="drive_Pair_Totals/Local"> <Totals l1="{l1_invalid_mbs}" l2="{l2_invalid_mbs}"/> </xsl:for-each> </xsl:element> </xsl:template> </xsl:stylesheet>
The XML Result: temp.xml
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <devices> <device name="Name 1" type="backup"/> <drive_Pair status="same" local="1234" remote="1234"/> <drive_Pair status="same" local="4321" remote="4321"/> <Totals l1="0.0" l2="0.0"/> </devices> <devices> <device name="Name 2" type="Active"/> <drive_Pair status="different" local="3425" remote="3542"/> <drive_Pair status="different" local="0362" remote="9876"/> <drive_Pair status="same" local="8767" remote="8767"/> <Totals l1="0.0" l2="0.0"/> </devices>
The issue I am having is when I validate the output XML, temp.xml it comes back with an error that happens right here (line 8 of temp.xml):
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<Totals l1="0.0" l2="0.0"/> </devices> <devices> #<--------- "Character 'D' is grammatically unexpected" <device name="Name 2" type="Active"/>
It references that the reason for the error is because it expects '!' or '?'.... And I am at a loss on how to "fix" it.
An XML document needs exactly one root element. So you should wrap your devices tags in another tag.
See: http://en.wikipedia.org/wiki/Root_element
See: http://en.wikipedia.org/wiki/Root_element
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Apr 2009
Posts: 44
Reputation:
Solved Threads: 2
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" standalone="yes" cdata-section-elements="devices" indent="yes"/> <xsl:template match="root"> <devices> <xsl:apply-templates select="device"/> </devices> </xsl:template> <xsl:template match="device"> <xsl:apply-templates select="device_Info"/> <xsl:apply-templates select="drive_Pair"/> <xsl:apply-templates select="Totals"/> </xsl:template> <xsl:template match="device_Info"> <device name="{name}" type="{type}"/> </xsl:template> <xsl:template match="drive_Pair"> <drive_Pair status="{status}" local="{Local/l_name}" remote="{Remote/l_name}"/> </xsl:template> <xsl:template match="Totals"> <Totals l1="l1_invalid_mbs" l2="l2_invalid_mbs"/> </xsl:template> </xsl:stylesheet>
![]() |
Similar Threads
- XML Bug Error. (XML, XSLT and XPATH)
- converting xml to xsl, formatting just right (XML, XSLT and XPATH)
- Refresh XML/XSL fails because XML page being updated (XML, XSLT and XPATH)
- ASP.NET - session objects Problem (ASP.NET)
- XML + XSL embedded into HTML (XML, XSLT and XPATH)
- some noobish questions about xml, xsl (XML, XSLT and XPATH)
- XML or XSL or What?? (XML, XSLT and XPATH)
- Help needed in simple app while using XML,XSL (XML, XSLT and XPATH)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: add xml declaration and namespace to xml output in sql
- Next Thread: XSLT group size
| Thread Tools | Search this Thread |
-xlint 429 actionscript3 activex ajax api application asp.net backup blogger blogging blue bsod business c# c++ char* class code compiler component computer delete development dns eclipse email embedded error file flash flipbook floatingpoint gdata gdi+ gmail google gui html input java javac jni kernel linker linspire linus linux management microsoft mistake news node nodes onreadystatechange openoffice optimisation output parse php port problem programming reformat return rss ruby screen serialization server small space standards swappingxmlfromflash swappingxmlnodes swf syntax tanenbaum tannenbaum text torvalds transform txttoxmlconverter undosend update vb vb2008 virus vista visual w3c web windows windowsxp xml xmlnotloading xmlonserver xsl xslt






