Click here to Skip to main content
15,921,210 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralSelect distinct nodes from XML File using VB.NET Pin
dnsl29-Jan-08 0:21
dnsl29-Jan-08 0:21 
GeneralRe: Select distinct nodes from XML File using VB.NET Pin
newc129-Jan-08 5:45
newc129-Jan-08 5:45 
GeneralXML Inheritence using XSLT Pin
Matty2228-Jan-08 13:20
Matty2228-Jan-08 13:20 
Generaldistinc or group by in xpatch Pin
sepel27-Jan-08 13:18
sepel27-Jan-08 13:18 
Generalnet4manpower need freelance webdesigner and software developer Pin
net4manpower26-Jan-08 8:06
net4manpower26-Jan-08 8:06 
GeneralWrite xsd for an Xml File Pin
VanithaVasu23-Jan-08 18:20
VanithaVasu23-Jan-08 18:20 
GeneralXML Parser using C++/VC++ Pin
QuickDeveloper20-Jan-08 20:04
QuickDeveloper20-Jan-08 20:04 
GeneralRe: XML Parser using C++/VC++ Pin
led mike24-Jan-08 5:07
led mike24-Jan-08 5:07 
QuestionHow to add an xml node such that validition of the file should not be failed? Pin
nicolus20-Jan-08 17:10
nicolus20-Jan-08 17:10 
QuestionRepresenting arrays of values in an XML file. Pin
Jack 292716-Jan-08 16:06
Jack 292716-Jan-08 16:06 
GeneralRe: Representing arrays of values in an XML file. Pin
George L. Jackson17-Jan-08 9:31
George L. Jackson17-Jan-08 9:31 
GeneralRe: Representing arrays of values in an XML file. Pin
led mike17-Jan-08 9:43
led mike17-Jan-08 9:43 
GeneralRe: Representing arrays of values in an XML file. Pin
George L. Jackson17-Jan-08 12:33
George L. Jackson17-Jan-08 12:33 
GeneralRe: Representing arrays of values in an XML file. Pin
led mike17-Jan-08 9:42
led mike17-Jan-08 9:42 
Questionhow to read xml using javascript? Pin
googlejumbo15-Jan-08 0:09
googlejumbo15-Jan-08 0:09 
AnswerRe: how to read xml using javascript? Pin
led mike15-Jan-08 6:24
led mike15-Jan-08 6:24 
GeneralDataGrid: view XML data Pin
aluisdo14-Jan-08 2:47
aluisdo14-Jan-08 2:47 
QuestionHow to filt some items when transform xml to html with xslt? Pin
guiqul16313-Jan-08 19:40
guiqul16313-Jan-08 19:40 
Generalschema Pin
justintimberlake12-Jan-08 17:53
justintimberlake12-Jan-08 17:53 
GeneralRead and Write an image into Xml Pin
shoukat12-Jan-08 17:21
shoukat12-Jan-08 17:21 
GeneralRe: Read and Write an image into Xml Pin
pmarfleet12-Jan-08 23:28
pmarfleet12-Jan-08 23:28 
GeneralConvert XML from one format to other format (depending on one XSD) Pin
coder_help11-Jan-08 0:07
coder_help11-Jan-08 0:07 
GeneralRe: Convert XML from one format to other format (depending on one XSD) Pin
led mike11-Jan-08 5:54
led mike11-Jan-08 5:54 
QuestionXSL - Transform Element Values to Attribute Name Pin
lisad_tgc10-Jan-08 12:47
lisad_tgc10-Jan-08 12:47 
I transformed an XML file as follows:

**** original XML ****

<?xml version="1.0" encoding="utf-8"?>
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pages>
<ele0>
<pageName>Test</pageName>
</ele0>
</pages>
</Data>


******* Transformed XSL *****

<?xml version="1.0" encoding="utf-8"?>
<main-menu-list>
<pageName pageName="Test" />
</main-menu-list>

**** XSL ***
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<main-menu-list>
<xsl:for-each select="//Data/pages/*">
<xsl:element name="pageName">
<xsl:attribute name="pageName">
<xsl:value-of select="pageName"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</main-menu-list>

</xsl:template>

</xsl:stylesheet>

However, I would like to transform any XML document as above without naming a specific element/attribute.
I found this XSL for starters but am having difficulty representing the element value in the attribute:

<?xml version="1.0" encoding="utf-8"?>


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="pageName">
<xsl:element name="{name()}">
<xsl:for-each select="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>


</xsl:stylesheet>

Any ideas?
GeneralRe: XSL - Transform Element Values to Attribute Name Pin
led mike11-Jan-08 5:48
led mike11-Jan-08 5:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.