[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

show all xml accessible to xsl stylesheet

Hi,

I have a xsl style sheet which is being called from a dll which I do not have the code for.  I need to know what the xml looks like so I can make modifications to the style sheet.  Is it possible to show the xml that is calling the stylesheet?

The closest thing I could find was Q_20283848 and since I'm not an xsl expert, I'm stuck.

Thanks
0
leos_
Asked:
leos_
  • 5
  • 4
  • 3
  • +1
3 Solutions
 
b1xml2Commented:
what are you referring to with this:
>>
Is it possible to show the xml that is calling the stylesheet?
<<

what do you want to do?
0
 
leos_Author Commented:
I am asking for xsl code which will show me all the elements and all the attributes which are available.
0
 
b1xml2Commented:
your question is not framed properly. Whenever a styleshee is loaded via the xml-stylesheet processing instruction, ipso facto, the entire Xml Tree of the document is available. What I think you want is the ability to change element and attribute names, values etc. The concept has been coined "element transformation". To make the concept clearer, give us an example of your xml document and what you want to change it to..

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leos_Author Commented:
The problem is that I do not have the xml.  I realize that I can access the entire xml, however it is hard to do when I do not know what the elements are called, nor what the attributes are called.  I would like to know the names of all the elements and attributes in the xml, if there are in fact any.

I expect the xsl I want would look something like this:  (this code certainly doesn't work, but is given as a demonstration of what I need)

<xsl:template match="*">
  <xsl:value-of select".">
  <xsl:for-each select="./@*">
    <xsl:value-of select="./@*"/>
  </xsl:for-each
  <xsl:call-template match="./*"/>
</xsl:template>

so basically I want the xsl to print out the xml.
0
 
KeirGordonCommented:
Do you know what XSL engine is being used?  Is it a microsoft application calling it?  Different versions allow different functionality, like creating seperate output files for instance.
0
 
KeirGordonCommented:
Where does the output of the transformation go? Can you see the output of the current XSl? becuase its not hard for us to give you XSL that will output the input unchanged.
0
 
KeirGordonCommented:
Well I think this is what you want:

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

  <xsl:template match="/ | @* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Won't be an exact copy, some whitespaces might be changed, etc, but it should be more than sufficient.
0
 
leos_Author Commented:
I'm using MSXML2.DOMDocument.3.0.

The transformation is sent in an email, so I can see the output, but it's really a pain in the neck to fix.

Your code looks like what I want. I'll give it a try and let you know.
0
 
jkmyoungCommented:
Why not simply:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>
?
0
 
b1xml2Commented:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="/ | @* | node()">
<xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy>
</xsl:template>

</xsl:stylesheet>

merely copies the xml document,

you might as well do it this way then:

<xsl:template match="/">
<xsl:copy-of select="." />
</xsl:template>
0
 
b1xml2Commented:
which jkmyoung has stated,
0
 
leos_Author Commented:
Thanks everyone! This works perfectly for a browser, you just look at the source and can see the original xml.

However, it doesn't work perfectly when the results are sent through our mail app.  Everything inside the <> tags is stripped.

Is there any way that the these results can be html encoded so that they show up in the browser, and thus, in my resulted email?

Thanks! If there is I'll increase points and split accordingly.
0
 
jkmyoungCommented:
Perhaps escaping the entities?? < > and "
Not sure if this is what you want. Also this basic template misses processing instructions and a few other things.

<xsl:template match="*">
  &lt;<xsl:value-of select="name()"/><xsl:value-of select="' '"/>
  <xsl:for-each select="@*">
    <xsl:value-of select="name()"/>=&quot;<xsl:value-of select="."/>&quot;
  </xsl:for-each>&gt;
  <xsl:apply-templates/>
  &lt;/<xsl:value-of select="name()"/>&gt;
</xsl:template>
0
 
leos_Author Commented:
Thanks, exactly what I needed.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now