Click here to Skip to main content
15,861,125 members
Home / Discussions / XML / XSL
   

XML / XSL

 
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 
QuestionCreation of xml-file based on schema? Pin
eroi10-Jan-08 3:53
eroi10-Jan-08 3:53 
GeneralRe: Creation of xml-file based on schema? Pin
led mike11-Jan-08 5:38
led mike11-Jan-08 5:38 
GeneralRe: Creation of xml-file based on schema? Pin
eroi14-Jan-08 3:32
eroi14-Jan-08 3:32 
GeneralRe: Creation of xml-file based on schema? Pin
led mike15-Jan-08 6:00
led mike15-Jan-08 6:00 
GeneralRe: Creation of xml-file based on schema? Pin
eroi17-Jan-08 1:06
eroi17-Jan-08 1:06 
QuestionHelp to incorporate an html code in xslt Pin
Ismailc9-Jan-08 21:01
Ismailc9-Jan-08 21:01 
Generaltransfer file Pin
angels7779-Jan-08 5:18
angels7779-Jan-08 5:18 
GeneralBest approach towards reading specific information from XML file Pin
Krishnaraj Barvathaya B8-Jan-08 22:46
Krishnaraj Barvathaya B8-Jan-08 22:46 
GeneralRe: Best approach towards reading specific information from XML file Pin
led mike9-Jan-08 4:46
led mike9-Jan-08 4:46 
Generalpicture problems in wpf Pin
angels7775-Jan-08 3:43
angels7775-Jan-08 3:43 
GeneralRe: picture problems in wpf Pin
Scott Dorman5-Jan-08 6:15
professionalScott Dorman5-Jan-08 6:15 
QuestionHow to get a specified attribute value using MSXML4 Pin
followait25-Dec-07 5:09
followait25-Dec-07 5:09 
AnswerRe: How to get a specified attribute value using MSXML4 Pin
CPallini28-Dec-07 9:59
mveCPallini28-Dec-07 9:59 
GeneralWhat's usually used to parse an XML file Pin
followait25-Dec-07 3:11
followait25-Dec-07 3:11 
GeneralRe: What's usually used to parse an XML file Pin
Scott Dorman5-Jan-08 6:36
professionalScott Dorman5-Jan-08 6:36 
GeneralRe: What's usually used to parse an XML file Pin
DavidNohejl14-Jan-08 3:13
DavidNohejl14-Jan-08 3:13 

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.