cancel
Showing results for 
Search instead for 
Did you mean: 

XSL help required.

Former Member
0 Kudos

Hi,

I am using the <xsl:copy-of> element to create a xml structure.

The output seems to be fine, except that, the nodes have a namespace attached to it. <i>copy-of</i> seems to be copying the current nodes and its child nodes "with namespace".

Is there any xsl element which has the same functionality of copy-of but which ignores namespaces while copying?

Regards,

Smitha.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Smitha,

Try using 'Value-of'. This will copy only the value of the source node.

Cheers

JK

Former Member
0 Kudos

Hi JK

I'm trying to make the XSL code generic.

Value-of element requires xpath as a value, which makes my code specific to a xml structure.

Any other suggestions?

Regards,

Smitha.

Answers (1)

Answers (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

send the input and desired output

maybe we'll be able to help you

Regards,

michal

Former Member
0 Kudos

Here goes the code:

XSL:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

<xsl:output method="text/xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="soapenv:Body">

<xsl:copy-of select="child::node()"/>

</xsl:template>

</xsl:stylesheet>

Expected XML structure:

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

<b><loginResponse></b>

<result>

<passwordExpired></passwordExpired>

<serverUrl></serverUrl>

<sessionId></sessionId>

<userId></userId>

</result>

</loginResponse>

The actual output generated is same as above except:

<<b>loginResponse</b> xmlns="urn:enterprise.soap.sforce.com">

The urn is getting added to the tag which is to be ignored.

Regards,

Smitha.

MichalKrawczyk
Active Contributor
0 Kudos

and the input ?

Regards,

michal

Former Member
0 Kudos

The input:

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

<loginResponse xmlns="urn:....">

<result>

<passwordExpired>false</passwordExpired>

<serverUrl>abc</serverUrl>

<sessionId>a123</sessionId>

<userId>smitha</userId>

</result>

</loginResponse>

Regards,

Smitha.

former_member206604
Active Contributor
0 Kudos

Hi Smitha,

Try this XSL


<?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" indent="no"/>

  <xsl:template match="/|comment()|processing-instruction()">
    <xsl:copy>
      <!-- go process children (applies to root node only) -->
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <!-- go process attributes and children -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>


Thanks,

Prakash

Former Member
0 Kudos

Thanks Prakash.

Will try this and get back.

Regards,

Smitha.

former_member206604
Active Contributor
0 Kudos

Hi Smitha,

Sure try it and let me know, I tried it with a simple existing structure it worked. Let see if it works fine in ur case.

Thanks,

Prakash