Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:07:35+00:00 2026-06-10T02:07:35+00:00

This is super straightforward stuff, it seems to me, but I cannot figure out

  • 0

This is super straightforward stuff, it seems to me, but I cannot figure out how to select a node in the following format using XPath:

<w:p>
            <w:pPr />
            <w:customXml w:uri="DxDitaOXmlPub" w:element="msgnum">
              <w:r>
                <w:rPr>
                  <w:rStyle w:val="Dxmsgnum" />
                </w:rPr>
                <w:t>Consult your compliance officer.</w:t>
              </w:r>
            </w:customXml>
          </w:p>

I have tried numerous variations on the following stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" 
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" 
xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
xmlns:o="urn:schemas-microsoft-com:office:office" 
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" 
xmlns:v="urn:schemas-microsoft-com:vml" 
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" 
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 
xmlns:w10="urn:schemas-microsoft-com:office:word" 
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" 
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" 
xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" 
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" 
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">

<!-- Identity Transform -->

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

<xsl:template match="w:p[descendant::w:rPr/w:rStyle/@w:val='msgnum']">

    <w:p>
        <w:pPr>
            <w:pStyle w:val="ActionRequired" />
        </w:pPr>
        <w:customXml w:uri="DxDitaOXmlPub" w:element="Dxmsgnum">
            <w:r>
                <w:rPr>
                    <w:rStyle w:val="Dxmsgnum" />
                </w:rPr>
                <w:t>
                    <xsl:value-of select="descendant::w:t"/>
                </w:t>
            </w:r>
        </w:customXml>
    </w:p>

</xsl:template>

</xsl:stylesheet>

The desired result is really nothing fancy, just modifying the w:pPr element to include a non-empty child w:pStyle:

 <w:p>
            <w:pPr>
                <w:pStyle w:val="ActionRequired" />
            </w:pPr>
            <w:customXml w:uri="DxDitaOXmlPub" w:element="Dxmsgnum">
                <w:r>
                    <w:rPr>
                        <w:rStyle w:val="Dxmsgnum" />
                    </w:rPr>
                    <w:t>
                        Consult your compliance officer.
                    </w:t>
                </w:r>
            </w:customXml>
        </w:p>

I don’t see any reason why the stylesheet doesn’t do what I want as-is, but I am not termendously familiar with the OpenXML format, so maybe there’s something funky I’m not aware of?

EDIT: I have also tried matching on the @w:element as follows:

<xsl:template match="w:p[child::w:customXml/@w:element='msgnum']">

        <w:p>
            <w:pPr>
                <w:pStyle w:val="ActionRequired" />
            </w:pPr>
            <w:customXml w:uri="DxDitaOXmlPub" w:element="msgnum">
                <w:r>
                    <w:rPr>
                        <w:rStyle w:val="Dxmsgnum" />
                    </w:rPr>
                    <w:t>
                        <xsl:value-of select="descendant::w:t"/>OOGA BOOGA!
                    </w:t>
                </w:r>
            </w:customXml>
        </w:p>

</xsl:template>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:07:37+00:00Added an answer on June 10, 2026 at 2:07 am

    Try something like this instead? Copies over nodes normally, except inserts your desired child in empty w:pPr elements that are children of a w:p element.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >
    
        <!-- Identity Transform -->
    
        <xsl:template match="/ | @* | node()" name="identity">
            <xsl:copy>
                <xsl:apply-templates select="@* | node() "/>
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="w:pPr[parent::w:p//@* = 'msgnum']">
            <xsl:copy>
                <w:pStyle w:val="ActionRequired" />
            </xsl:copy>
        </xsl:template>
    
    </xsl:stylesheet>
    

    Edit: Could you clarify what counts as an acceptable check? Any element containing an attribute equals to “msgnum”? I fixed the template match to reflect this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This must be rather trivial and straight forward, but I cannot figure it out.
Seems like this should be super-simple but looking around for a simple (or half-way
This should be super simple. The first code block works, but when I wrap
This may be super easy to solve but I can't find the correct google
This may be super simple - but I'm struggling to spot what's going on.
I have the following jQuery: $(form).submit(function() { //DO STUFF HERE }); But, it's not
I know this isn't a straightforward question but I would really appreciate some feedback
This might be a dumb question but I can't get this super simple script
This should be a pretty straightforward classes and interfaces question, but please bear with
I just tossed this super simple code example into a Flash CS4 IDE frame

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.